I have an combo box with column head on.
there are three columns in the combo box
column 0 id (hidden)
Column 1 description
column 2 type
After selecting an item from the list box I execute code to get the quantity available from a table in the database
the code is below.
if I select any other item but the first one in the combo box the code works just fine.
if I turn column head off the code works fine.
If I select the first item in the combo box with column head on I get an error. Type mismatch on the line in red.
Debugging the code it looks like when I try to select the first item in the combo list instead of returning the value of the id for that item it is returning the column head of "ID"
Code:
Private Sub iDescription_AfterUpdate() Dim selected, selectedid As Integer
selected = Me.iDescription.ListIndex
selectedid = Me.iDescription.Column(0, selected)
Me.type = Me.iDescription.Column(2, selected)
me.qtyavailable = DLookup("quanity", "inventory", "ID =" & selectedid)
Me.iprice.SetFocus
End Sub
I am using Access 2007.
any Ideas?