Multiple list/combo box problem ??

  • Thread starter Thread starter thesquire
  • Start date Start date
T

thesquire

I have a requirement for 2 list/combo boxes.

The 1st one named 'category', and the 2nd named 'sub category'.

How can I get the list that is available in the 'sub category' to
change subject to the contents selected in the list in the 'category'.
 
I've set cbxCombo1 RowSourceType to "Value List" and RowSource to a
typed list of "data1";"date2" etc..

Also cbxCombo2 doesn't have anything under RowSource and
RowSourceType.

In the AfterUpdate event of cbxCombo1 the following code has been
added

'**************** Code Start *************
Private Sub cbxCombo1_AfterUpdate()
Dim strSQL As String
strSQL = "Select " & Me!cbxCombo1
strSQL = strSQL & " from Categories"
Me!cbxCombo2.RowSourceType = "Table/Query"
Me!cbxCombo2.RowSource = strSQL
End Sub
'**************** Code End *************

However I get a run time error message 438 come up, refering to
"Object doesn't support this property or method (Error 438)" on
Me!cbxCombo2.RowSourceType = "Table/Query"

In checking cbxCombo2.RowSourceType, which was empty. It now has
Table/Query in it ???

Any ideas why error 438
 
I can't see anything wrong with that code, and I double-checked by testing
very similar code here. Did you post your actual, copied-and-pasted code, or
did you re-type the code into the newsgroup post? If the latter, try copying
and pasting, possibly there might be some typo in the original code. If not,
I'm afraid I don't know what the problem is.
 
I've managed to get it going in a away. code as follows.

Private Sub cbxCombo1_AfterUpdate()
Dim strSQL As String
If Me!cbxCombo1.Text = "test1" Then
strSQL = "Select cat2.cat2 FROM cat2;"
End If
If Me!cbxCombo1.Text = "test2" Then
strSQL = "Select cat3.cat3 FROM cat3;"
End If

Me!cbxCombo2.RowSourceType = "Table/Query"
Me!cbxCombo2.RowSource = strSQL
End Sub
 

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

Back
Top