Reputation:
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.
Upvotes: 4
Views: 6386
Reputation: 460
Don't forget allow edits at the form level as well even if you want everything read only. For me the listbox was only selectable when I set both to allow edits.
Upvotes: 0
Reputation: 765
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.
Upvotes: 2