Cascading Drop Down Menu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to make two menus cascade. There are to different tables
"services" and "carriers" I would like to select the carrier first and then
show all of the services for the selected carrier. How would I do this. I
need to store the selected answer, and I have unique ids for each table.
 
Hi James

There are two ways to do this. The simplest is to base the RowSource of
your second combobox on a query which is filtered by the first. For
example, your RowSource for cboService could be:
Select ServiceID, ServiceName from Services where
ServiceCarrier=Forms![YourFormName]!cboCarrier;

In the AfterUpdate event procedure for the first combobox, you need to
requery the second one:
cboService.Requery

If the comboboxes are on a subform, this method becomes a bit unwieldy. And
if the subform is used on two or more different main forms then it doesn't
work at all. In this case, you need to respecify the second combo's
rowsource when the first one changes. So, in cboCarrier_AfterUpdate:
Dim sRowSrc as String
sRowSrc = "Select ServiceID, ServiceName from Services where "
& "ServiceCarrier=" & Nz(cboCarrier)
cboService.RowSource = sRowSrc
 
Back
Top