I have a multiselect listbox, 10 columns. I want to be able to type in a textbox, hit a button, and the thing I typed in is highlighted in the listbox. The search should be through column 1 of the listbox.
Use the following code in your button's click event:
Dim intRow As Integer
For intRow = 0 To Me!YourListBox.ListCount - 1
If Me!YourListBox.Column(0, intRow) = YourTextBox.Value Then
Me!YourListBox(intRow).Selected = True
Exit For
End If
Next intRow
A couple of things to note, in the column property you will use the column number that holds the data of interest, if the data is in the bound column you can use .ItemData(intRow) instead. Doing the search this way allow for an exact match only, so if no match is found(you can use a boolean variable to track that) you may want to display a message box with an appropriate comment.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.