Search Box & Combo Box

G

Guest

I've created a search form such that the user can input a keyword into a text
box and it will search for that keyword in a number of different fields.

ie. lets say my fields are
Name, Address, City, Zipcode, Phone number

A keyword search for any value will display results found in all of those
fields.

What I want to do now is create a combo box that can limit the keyword
search to one of those fields, or include all of them. (Search All, name
only, address only, city only, etc etc.)

Any help?

Thanks a lot guys.
 
J

JP

Create a combo box that has as its values "--ALL--" and then the names of
the individual fields.

When the user enters the string to search on and selects the type of search
from the combo box, you then build an SQL string. Essentially it's
something like this:

If me.combobox.value = "--ALL--" then
sFilter = "select * from table where field_1 = '" & me.txbSearch_String
& "' or field_2 = ' " & me.txbSearch_String & "' or ....
else
sFilter = "select * from table where " & me.combobox.value & " = '" &
me.txbSearch_String & "'"
endif

Then make sFilter the filter for your results display form
 

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

Similar Threads


Top