Combo Box, filter values

  • Thread starter Thread starter Celfreak
  • Start date Start date
C

Celfreak

For a combo box I use a sql statement as basis.

SELECT Klanten.Bedrijf FROM Klanten ORDER BY Klanten.Bedrijf;

When I using the form, the list goes automatically to the name with the
(first) letters you type in the box. My problem is the list is getting bigger
and bigger, so I want to search in my combobox.

In SQL you can use the Where statement to narrow down the choices. For example
SELECT Klanten.Bedrijf FROM Klanten WHERE Klanten.Bedrijf Like '*BV*' ORDER
BY Klanten.Bedrijf; narrows down the list of the combobox the the values with
BV in their name.

This is a static statement and i want to make it more dynamic. What I want
is to have a (independent) field where you type your searchword that is used
by the combobox to narrow down the list. I tried many things, only I cannot
connect a field to the SQL statement.

What works is voor example
SELECT Klanten.Bedrijf FROM Klanten WHERE Klanten.Bedrijf Like '*'&
searchword &'*' ORDER BY Klanten.Bedrijf

I then get the message give parameter. Problem with this is that I cannot
change that parameter.
 
Try changing your last SQL statement to:

"SELECT bedrijf FROM klanten WHERE bedrijf Like '*" & SearchWord & "*'" & "
ORDER BY bedrijf"

That is after the word Like you'll see one apostroph an asterisk and double
quotes. After the second & you'll find a double quote an asterisk a single
quote and a double quote.

That will do the trick you are looking for.
hth
 
Back
Top