Unanswered: Listbox - How to highlight desired row
I am opening a form with a listbox (that I populate with a dynamic sql query) and it works fine.
Now I would like to jump to the row in the listbox that contained the user's search term. It will be in the first column of the listbox.
I tried the following, but it does not work. Can someone please tell me how to highlight the desired row of a listbox?
Dim ctl as control, txtSearchTerm as string, itemfound as variant
Set ctl = Me!mylistbox
For Each Item in ctl
if ctl.Column(0, Item) = txtSearchTerm then itemfound = Item
ctl.Selected(itemfound) = True
No. Unfortunately, the form I am opening (which contains ths listbox in question) cannot be bound. I really think I need to loop through each of the listbox items to search for my text string. I don't know why my FOR EACH doesn't work with a listbox control in Access...?