How to get matching values with combo box and dropdown property?

J

Jack Darsa

Hello,
Previous i asked the same question but now i can explain it better. I need
exactly the same functionalty if a combox with dropdown property enabled.
The extra feature i need is: To not limit the selection to the first
character only from the list ,but to be able select the values from the
middle (any location) of the string .I have seen examples of that
functionality. I think it maybe a commercial activex control ,but i did not
find any.
Here is also an example of what i need.
The combo box is populated with the following values.
12345
23451
34512
45123

user types (one by one ) the combobox shows the dropdown list
shows
1 1
12345,23451,34512,45123
2 12
12345,34512,45123
3 123
12345,45123

At that step the user can select anything from list either by completing
according to the values or by using the mouse. The reason i need it to
filter a geographic data base where the address field includes the full
address (street,drive,west,east,house number etc..). So when types just
"east" he will get all the addresses containing the word "east" at the drop
down list.
BTW if anybody knows any commercial addin that does the job without
programming i would like to know about it.
Thank you
 
J

Jeff Boyce

Jack

It sounds like you've already limited the solution to a combobox with a
special dropdown property. If you aren't "welded" to that, there may be
other solutions.

For example, if you created a text box for the "search string", and used the
OnKeyPress event to 'read' what had been entered, you could also use that
event to dynamically run a SQL statement (i.e., a query) that searches for
the target string using the "Like" operator and the "*" wildcard. In fact,
you wouldn't even have to write SQL, as you could do this in a query.

You could then use the results of the query to load a listbox with the
"found" records, and select from that listbox to go to the one you want.
 
W

Wayne Morgan

This might be easier to do with a textbox and a listbox. Set the Row Source
for the listbox in the textbox's Change event. Changing the Row Source for
automatically requery the listbox.

Example:
Private Sub Text0_Change()
Me.List2.RowSource = "SELECT Test1 FROM Table1 WHERE Test1 Like ""*" &
Me.Text0.Text & "*"";"
End Sub
 
J

Jack Darsa

Is there a way to do this without a textbox ?
I mean just using the combox and an event or property that does it ?
Thank you
 
W

Wayne Morgan

I just tried the following in a combo box and it appeared to work.

Private Sub Combo0_Change()
Me.Combo0.RowSource = "SELECT Test1 FROM Table1 WHERE Test1 Like ""*" &
Me.Combo0.Text & "*"";"
End Sub
 

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