Combo Box Search Field

J

Jon Barker

HI,

I am currently making a database where i have a table which i would like to
search. I am running an SQL command from a form with the criteria linked to
a textbox. I would also like to link the condition (search field name) to a
combo box which is on the same form. I cannot seem to find out how to do
this. Below is my SQL statement that i am currently using which works fine.

SELECT *
FROM tbl_inmateinfo
WHERE surname Like "*" & Forms!frm_search!text1 & "*";

What i would like to do is make the surname (searchable field name) value a
variable which is obtained from the combo box on the form.

If anyone could help it would be greatly appreciated!

Thanks
 
J

John Spencer (MVP)

As Far as I know, you cannot do this directly in the query. You would need to
use vba to construct the query on the fly.

Depending on where you want to use the query results - in a form or a report -
you could remove the WHERE clause from the query and build a filter for the form
or report when you call it.
 

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