Listbox Search Modes?

Stang70Fastback

Registered User.
Local time
Today, 09:04
Joined
Dec 24, 2012
Messages
132
By default, as you type into a listbox, it searches in a "starts with" fashion. Is it possible to configure a listbox to search in a "contains" manner?

For example, if the listbox contains 4 entries:

This is a test
Testing 123
Also another test
Macaroni and Cheese

And I start typing "test" into the box, I'd like for the list to display:

This is a test
Testing 123
Also another test

Currently, all that I would see is:

Testing 123
 
you could put a text box above the list box.
THEN it could filter the list box in the AFTERUPDATE event of the txt box.

the list box query = qsListAll
Code:
 sub txtFilterList_afterupdate()
    if isnull(txtFilterList) then
       lstBox.rowsource = "qsListAll"
    else
       lstBox.rowsource = "qsListFilter"
    endif
    lstBox.requery
 end sub
the qsListFilter uses the text box in the query
select name from table where like "*" & txtFilterList & "*"
 
To re-search for every keystroke use the Change event and the Text property, like . . .
Code:
sub txtFilterList[COLOR="Blue"]_change[/COLOR]()
    lstBox.rowsource = "SELECT * FROM qsListAll WHERE testField LIKE '*" & me.txtFilterList[COLOR="Blue"].Text[/COLOR] & "*'"
    lstBox.requery
end sub
 

Users who are viewing this thread

Back
Top Bottom