Update the values of a subform on a mainform

BittenApple
BronzeLounger
Posts: 1498
Joined: 01 Mar 2015, 02:03

Update the values of a subform on a mainform

Post by BittenApple »

Hello all,

I have a main form with a combo box on it. When I select an item from combo box, it has to populate the subform. Actually, it works; but I have to click on the subform to get the subform populated. It takes a click.
Could it be possible to write a VBA code to update subform automatically without clicking on the form?

Regards,
lebi

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Update the values of a subform on a mainform

Post by HansV »

You could create an After Update event for the combo box:

Code: Select all

Private Sub Combo1_AfterUpdate()
    Me.Subform1.Requery
End Sub
where Combo1 is the name of the combo box and Subform1 is the name of the subform as a control on the main form.
Best wishes,
Hans

BittenApple
BronzeLounger
Posts: 1498
Joined: 01 Mar 2015, 02:03

Re: Update the values of a subform on a mainform

Post by BittenApple »

Hello Hans,
I started a new database, the second form was populated after I selected an entry from the combo box. However, I put the code on the after update event of combo box for days that the form doesn't get populated automatically. Very nice code.
Regards,
Biiiittt