Reputation: 67
I'm new to VB and trying to populate combo box in access from a select query's result which is getting value from another combo box and the code that i'm trying is:
Private Sub addPartsButtonForm_Click()
ssql = "SELECT * FROM EquipmentTbl WHERE [EquipmentID] = '" & Me.equipmentCombo.Column(0) & "'"
Me!comboParts = ssql
Me.comboParts.Requery
End Sub
and when i press the button i got the following result in combo box:
SELECT * FROM EquipmentTbl WHERE [EquipmentID] = '34'
though its giving me the exact equipmentID but expected is something else other than that. Please help me
Upvotes: 0
Views: 2269
Reputation: 12353
Set the combo RowSource. Also, no need for quotes in case field is Number.
Dim sSql As String
sSql = "SELECT * FROM EquipmentTbl WHERE [EquipmentID] = " & Me.equipmentCombo.Column(0)
Me.comboParts.RowSource = ""
Me.comboParts.RowSource = sSql
Upvotes: 2