Ok... I have two comboboxes, cmb1 and cmb2... I have cmb1 rowsourcetype = FieldNames and rowsource = tblInfo. What I would like it to do is populate cmb2 with the list of values based on the users selection of cmb1.
From what I have found and read... This needs to be done in VBA based on the changing rowsource... however, I tried this and I can't seem to get it to work. I keep getting an error that: Procedure Declaration does not match description of event or procedure having the same name...
Here is the VBA:
The Form_Load and cmb1_AfterUpdate are set to call the procedure...
Any thoughts?
From what I have found and read... This needs to be done in VBA based on the changing rowsource... however, I tried this and I can't seem to get it to work. I keep getting an error that: Procedure Declaration does not match description of event or procedure having the same name...
Here is the VBA:
Code:
Private Sub FindValue()
'Build a SQL statement to pull unique values
'from whatever field name is selected in the form
'if cmb1 is empty, do nothing
Dim MySQL As String
MySQL = "SELECT DISTINCT" + cmb1.Value
MySQL = MySQL + " FROM " + tblInfo
MySQL = MySQL + " WHERE " + cmb1.Value Is Not Null
MySQL = MySQL + " ORDER BY " + cmb1.Value
'Make SQL the rowsource
Me!cmb2.RowSourceType = "Table/Query"
Me!cmb2.RowSource = MySQL
'Get SearchValue to show something from the drop down list
Me!cmb2.Requery
Me!cmb2.Value = Me!cmb2.ItemData(0)
End If
End Sub
The Form_Load and cmb1_AfterUpdate are set to call the procedure...
Any thoughts?