Dynamically Filter ComboBox With User Input

Y

YisMan

Hello everyone,
I'm trying to figure out something, and the problem boils down to this:
I have a simple form with 1Combobox and 1 textbox. the combobox's rowsource
is set to "qrPersons". I want that as the user types it should filter itself
to all names containing the user input, not necessarily according to the
first letters. so i added this code:

Private Sub cbFilter_Change()
cbFilter.RowSource = "select * from qrpersons where personname like '*"
& cbFilter.Text & "*'"
cbFilter.Dropdown
End Sub

simple enough. the filtering happens dynamically and it's beautiful. now if
the user chooses a row from the dropdown then everything is ok. the problem
is only if the user types, i.e. "Smit" and the combobox kindly shows "Smith,
John" in the combo and the user presses enter or tab, the combo does not
"catch" the value and ends up staying blank.
why is that? and what can be done about it?

I didn't really find any posts with such a question. I did find similiar
threads recommending to use control.requery, but that gives me an error 2118.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top