Search data from multiple fields using operator “OR” with a fild combobox or listbox

MS Access Questions and AnswersCategory: MS Access General QuestionSearch data from multiple fields using operator “OR” with a fild combobox or listbox
Kia Chouarolee asked 4 months ago

I have created a search form with multiple filds and the code that is not corectly to search the text from the Listbox as your exsample here: 

strsearch = Me.txtSearch.Value
Task = "SELECT * FROM tbl_customer WHERE ((CustomerName Like ""*" & strsearch & "*"") OR (city Like ""*" & strsearch & "*"") OR (Address Like ""*" & strsearch & "*""))"
Me.RecordSource = Task

Now, The City fild is my Listbox. So When I type the name of city that is not crrect. But If I type a number, the search form will show the information that I wanh. So how to change the city text to city listbox.
Thak you

1 Answers
TGoldenEye Staff answered 4 months ago

normally combo box and list box are linked to the ID field of another table. So the city in list box has the CityID (number) as the identifier and has the city name as a display. when you type a number then it will be looking for the CityID of that city, you will get the result of that city.
for the combobox or listbox that links to another table, you will need an extra code to look for the cityID of the city name that you type in.
 

Your Answer