Contextual drop down list

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

Guest

Hi
I have a form with 2 drop down lists. Drop down list #1 is the category
(state), #2 is the sub-category (cities).
I would like to display the sub-category drop down list based on the
category selected in drop down list #1. In other words, if california is
selected in list #1, display california cities in list #2, but if Nevada is
selected, display Nevada cities, etc...
How do i do that?
Thx in advance
Vince
 
In AfterUpdate event for dropdown #1:

If IsNull(DropDown1) Then
'Clear row source
DropDown2.RowSource = ""
Else
'Set row source as appropriate, for example ...
DropDown2.RowSource = "SELECT City FROM Cities WHERE State = '" &
DropDown1 & "'"
End If
'Clear any previously stored data in DropDown2 if DropDown1 has changed value
If DropDown2.ListIndex < 0 Then
DropDown2 = Null
End If
 
Back
Top