SQL Statement Variable

  • 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_info
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
 
Nearly there. . .

SELECT * FROM tbl_info WHERE [" & Forms!frm_search!comboboxname & "] Like
"*" & Forms!frm_search!text1 & "*"
 
Back
Top