Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Like and or help needed

Status
Not open for further replies.

maverickmonster

Programmer
May 25, 2004
194
GB
Hi this is my first SQL query I have tried to make in access never used SQL before and i have a problem.

im trying to search thought the Helpfile form for keywords and open them up,

eg search for 'Upload' and the results would find 'Uploading','upload files' etc

This is my code i think there is a problem with the ors

Also i have txtsearch in this formula how do i reference this to a form and a field

Code:
SELECT * FROM Helpfile WHERE (keywords Like 'txtsearch%')
OR (keywords Like '%txtsearch%') 
OR (keywords Like '%txtsearch')
SELECT Helpfile.HN, Helpfile.Keywords, Helpfile.HelpInfo, Helpfile.Group, Helpfile.SubGroup
FROM Helpfile;
 
eh, your posted sql doesn't make any sense at all...

that seems to be 2 seperate sql statements, doing different things...

firstly, you can't use sql to search on forms, well, you can but it's different... What you need to do is to bound a form to a record, and use sql to find that record.
In this case, you would need to have something like:
Code:
"SELECT * FROM tblName WHERE (keywords Like '" & txtsearch & "*') OR ..."
because you need to reference txtsearch instead of casting it as a string...
 
Ok i now have this
Code:
SELECT * FROM Helpfile WHERE (keywords Like '" & txtsearch & "*') OR (keywords Like '*" & txtsearch & "*')  OR  (keywords Like '*" & txtsearch & "')

Which seams to compile ok but how do i reference the txtsearch to a table or form ?
 
Say you have an open form named frmSearchHelp with a TextBox named txtSearch, then your saved query may look like this:
SELECT * FROM Helpfile
WHERE keywords Like '*" & [Forms]![frmSearchHelp]![txtSearch] & "*');

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
eh, for the actual like statement, if you put the * in front and behind the search string, then it'll include all instances of that string, so really no need to put 3 or statements in!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top