I am populating a listbox on an MS Access 2010 form with results from a stored procedure. The code I am using to populate the listbox is as follows:
Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("PassThroughQuery")
qdf.SQL = "EXEC Search '" & searchValue & "'"
Set rs = qdf.OpenRecordset
While Not rs.EOF
Me.searchResultsBox.AddItem rs("name")
rs.MoveNext
Wend
The query runs fine and the ListBox populates with the specified values, however the items in the list box are not selectable. I cannot click and highlight any of the items.
I checked the Enabled and Locked properties and they are set to True and False respectively. The "Row Source Type" is set to "Value List". I'm at a loss as to why the listbox values are behaving as the are.
I ran into the same problem: apparently listbox items are only selectable when editing is allowed. Maybe the forms Allow Edits property is set to false. It may also be that results from a pass through query or a stored procedure are not editable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With