PDA

View Full Version : Cascading ComboBoxes



sirT
07-12-2010, 01:41 PM
Hi, I'm not a programmer and I've been having an awful time trying to figure out the errors.

I'm just trying to get combobox2 to change according to combobox1 and combobox3 to change according to combobox 1 and 2, etc. for 5 comboboxes.

I've been experimenting and I got as far as the code posted below targeting combobox3. My problem is I get an error if I don't comment out the Me.ComboBox3.RowSource = strSQL and Me.ComboBox3.Requery.

Please give me a solution!! Thank you

Private Sub ComboBox2_AfterUpdate()
Dim upBrand As String
Dim upCategory As String
Dim strSQL As String

strSQL = Me.ComboBox3.Value

upBrand = Me.ComboBox1.Value
upCategory = Me.ComboBox2.Value

strSQL = "SELECT [Price] " & "FROM tblCombinedData" & "WHERE tblCombinedData.Brand= '" & upBrand & upCategory & " " & _
"ORDER BY tblCombinedData.Price;"

Me.ComboBox3.RowSource = strSQL
Me.ComboBox3.Requery

End Sub