Click to See Complete Forum and Search --> : search for simliar text


catgirl78
March 17th, 2001, 02:37 PM
My VB application provides a search facility for user to search for a particular restaurant.
the application allow the user to enter the restaurant name and search against the database (MS access) and return with record that have similar name.
i use the SQL:
Search_Data1.DatabaseName = App.Path & "\eat&go out guide.mdb"
Dim qry

qry=" SELECT Restaurants.RestName FROM Restaurants"
qry = qry + " WHERE Restaurants.RestName LIKE" + "'" + "%" text1.text + "%" + "'"

Search_Data1.RecordSource = Qry
so if the user enter "royal" in the text box, it should return all records with name that had "royal" ..but it doesn't work..
can anyone tell me what is wrong with the query....thanks

Sean Wilkening
March 17th, 2001, 03:12 PM
Access does not use the % character as a wildcard, instead it uses the * character. Try this queury instead.

qry=" SELECT Restaurants.RestName FROM Restaurants"
qry = qry + " WHERE Restaurants.RestName LIKE" + "'" + "*" text1.text + "*" + "'"

Search_Data1.RecordSource = Qry




I hope this helps you.

Sean Wilkening
IVR/CTI Programmer Analyst

Iouri
March 17th, 2001, 06:53 PM
qry=" SELECT Restaurants.RestName FROM Restaurants"
qry = qry + " WHERE Restaurants.RestName LIKE '%" & text1.text & "%'"


Iouri Boutchkine
iouri@hotsheet.com