BaldyWeb

The Selections in one Combo Box are Dependent on Another

This is typically referred to as "cascading" combo boxes.  Generally there are 2 ways to accomplish this. 

One is to have the row source of the second combo refer to the first in its criteria, then requery the second combo in the After Update event of the first.  The code would look like this:

Me.cboCities1 = vbNullString  'to clear the second combo
Me.cboCities1.Requery

The second method modifies the row source of the second combo when the first changes.  That code would look like this:

Dim strSource As String

strSource = "SELECT City " & _
                   "FROM Cities " & _
                   "WHERE State = '" & Me.cboState2 & "' ORDER BY City"
Me.cboCities2.RowSource = strSource
Me.cboCities2 = vbNullString

 

Cascading Combo sample db

Home