Question on Combo Boxes

  • Thread starter Thread starter Mantok
  • Start date Start date
M

Mantok

I have a pair of combo boxes. Via SQL, the second uses
the value in cmbFirst to narrow the possible choices. The
first time one uses the form to select the cmbSecond, the
values are correct. But if the user reselects a different
value for cmbFirst, the values in cmbSecond are not
repopulated.

How do I get the values to repopulate?

code:
SELECT DISTINCTROW tblexample.value2 FROM tblexample GROUP
BY tblexample.value2, IIf(IsNull([cmbFirst]),1=1,
([tblExample].[value1])=[cmbFirst]) HAVING (((IIf(IsNull
([cmbFirst]),1=1,([tblExample].[value1])=[cmbFirst]))
=True)) ORDER BY tblExample.value1;
 
Mantok said:
I have a pair of combo boxes. Via SQL, the second uses
the value in cmbFirst to narrow the possible choices. The
first time one uses the form to select the cmbSecond, the
values are correct. But if the user reselects a different
value for cmbFirst, the values in cmbSecond are not
repopulated.

How do I get the values to repopulate?

code:
SELECT DISTINCTROW tblexample.value2 FROM tblexample GROUP
BY tblexample.value2, IIf(IsNull([cmbFirst]),1=1,
([tblExample].[value1])=[cmbFirst]) HAVING (((IIf(IsNull
([cmbFirst]),1=1,([tblExample].[value1])=[cmbFirst]))
=True)) ORDER BY tblExample.value1;


Use the first combo's AfterUpdate event to Requery the
second combo box.
 

It's a method of the combo box object that causes the
control to rerun its row source query.

One line of VBA code in the AfterUpdate event procedure:

Me.nameofsecondcombobox.Requery
 
Back
Top