cascading combo help

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?
 
B

Beetle

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
 
B

Brad

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
 
S

Steve Sanford

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
 

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