Question on Combo Boxes

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;
 
M

Marshall Barton

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.
 
M

Marshall Barton


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top