Data can not update

S

Shell

I made a form with two combo box in it. The second combo box is a list based
on the condition of the first combo. But when I changed the data of the first
combo , the data of the second combo didn't change accordingly.
 
K

Ken Snell \(MVP\)

Do you run code in the AfterUpdate event of the first combo box that
requeries the second combo box? You need to do that.

Private Sub FirstComboBoxName_AfterUpdate()
Me.SecondComboBoxName.Requery
End Sub
 
K

Ken Snell \(MVP\)

I gave you the code in my reply. But perhaps you are not familiar with how
to put that code into your form?

Open form in design view. Click on the first combo box control. Right-click
and select Properties from the menu. Click on Event tab in the Properties
window. Click in box next to After Update property. Select [Event Procedure]
from the dropdown list in that box (click the combo box arrow at far right
of this box). Click on three-dot button at far right of the box, which will
open the Visual Basic Editor. In that window, you'll see a line of code that
starts with Private Sub, a blank line, and then a line of code that says End
Sub. In the blank line, type this code step (replace my generic
SecondComboBoxName text with the real name of the second combo box):

Me.SecondComboBoxName.Requery


Save the form and close it. The second combo box now will be requeried after
you make a selection (or type a value) into the first combo box.
 
Top