cascading combo help

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I have 3 combo boxes on a form that cascade. I set this up by using the
following code in the after update section of the preceding combo box.

cboRow.RowSource = "SELECT DISTINCT tblSeatType.Row " & _
"FROM tblSeatType " & _
"WHERE tblSeatType.Model = '" & cboModel.Value & "' " & _
"ORDER BY tblSeatType.Row;"

My question is if I select an option from the 1st and 2nd combo boxes, the
values will be available for the 3rd combo box; but if I went back and
changed my selection in the 1st combo box without changing the 2nd combo box,
the values in the 3rd combo box would not be changed. How can I resolve this
to update the 3rd combo box anytime either of the first 2 combo boxes are
changed?
 
Requery the 3rd combo box in the After Update event of the first
combo box (after your code to set the row source of the second
combo box).

Me!cboRow.Requery
 
No luck on that...here's what i have. cboModel -> cboRow -> cboSeat
(<-Combo's 1, 2, 3). And here's the code I have

Private Sub cboModel_AfterUpdate()

On Error Resume Next

cboRow.RowSource = "SELECT DISTINCT tblSeatType.Row " & _
"FROM tblSeatType " & _
"WHERE tblSeatType.Model = '" & cboModel.Value & "' " & _
"ORDER BY tblSeatType.Row;"

Me!cboSeat.Requery

End Sub

Private Sub cboRow_AfterUpdate()

On Error Resume Next

cboSeat.RowSource = "SELECT DISTINCT tblSeatType.Seat " & _
"FROM tblSeatType " & _
"WHERE tblSeatType.Model = '" & cboModel.Value & "' " & _
"AND tblSeatType.Row = '" & cboRow.Value & "' " & _
"ORDER BY tblSeatType.Seat;"

End Sub
 
I don't like setting up cascading combo boxes like that. Why keep setting the
rowsource every time you make a selection??

For each combo box, open the properties dialog box and set the rowsource
property.

In the afterUpdate event for cboModel, I have

Private Sub cboModel_AfterUpdate()

Me!cboRow = NULL
Me!cboSeat = NULL

Me!cboRow.Requery
Me!cboSeat.Requery

End Sub

And in the afterUpdate event for cboRow:

Private Sub cboRow_AfterUpdate()

Me!cboSeat = NULL
Me!cboSeat.Requery

End Sub

To me, this is simpler


HTH
 
Back
Top