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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select query with WHERE contains some word 2

Status
Not open for further replies.

davyre

Programmer
Oct 3, 2012
197
AU
Hi,

I need to write a query that selects records from TblOrder where the field OrderDesc contains word "Automatic".

Code:
selectAutoOrder = "SELECT * FROM TblOrder WHERE OrderDesc LIKE * Automatic * "

it says syntax error (missing operator). Anyone can help? Thnaks
 
thanks, it worked. But then if i use the code
Code:
counter = autoOrderRS.RecordCount
MsgBox (counter)

It shows wrong value, i.e in my table there are 6 records containing Automatic word, while the msgbox only show 1.

how do I change the code
Code:
selectAutoOrder = "SELECT * FROM TblOrder WHERE OrderDesc LIKE ""*Automatic*"" "
to select * from TblOrder WHERE OrderDesc LIKE (someVariable) ? So instead of using string "Automatic", I'd like to use a variable contain value "Automatic". Can you help? Thanks
 
Code:
selectAutoOrder = "SELECT * FROM TblOrder WHERE OrderDesc LIKE '*" & someVariable  & "*'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top