I have a form with textbox for searching records which populates a listbox. My SQL for the query is:
This search works good if I type in information from one field. I.e if i want to search on schoolname then i begin typing in the schoolname and it filters out the records.
However, what I want to be able to do is search on as many of the fields at once. I.e search by schoolname and postcode so it brings up anything with containing the schoolname and/or the postcode
How would I incorporate this into the SQL statement
Thanks
Code:
SELECT tblSchools.SchoolID, tblSchools.SchoolName, tblSchools.Phone, tblSchools.AddressLine1, Postcode.Postcode FROM tblSchools INNER JOIN Postcode ON tblSchools.PostcodeID=Postcode.PostcodeID WHERE (((tblSchools.SchoolID) Like "*" & Forms!frmSearch!Search2 & "*")) Or (((RemovePunc(tblSchools.SchoolName)) Like "*" & Forms!frmSearch!Search2 & "*")) Or (((tblSchools.Phone) Like "*" & Forms!frmSearch!Search2 & "*")) Or (((tblSchools.AddressLine1) Like "*" & Forms!frmSearch!Search2 & "*")) Or (((Postcode.Postcode) Like "*" & Forms!frmSearch!Search2 & "*"));
This search works good if I type in information from one field. I.e if i want to search on schoolname then i begin typing in the schoolname and it filters out the records.
However, what I want to be able to do is search on as many of the fields at once. I.e search by schoolname and postcode so it brings up anything with containing the schoolname and/or the postcode
How would I incorporate this into the SQL statement
Thanks