Combo Box Search Field

  • Thread starter Thread starter Jon Barker
  • Start date Start date
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
 
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.
 
Back
Top