JET SQL should accept the single-quote as a delimiter for a string within a
string. However, this fails as soon as a word contains an apostrophy. It is
preferable, therefore to use the double-quote.
Since VBA strings are delimited with the double-quote character, you cannot
have a string like this:
"This "word" is in quotes" ' <= error!
VBA gets to the quote before "word", thinks the string is finished, and has
no idea what to do with the rest of the line. The convention to solve this
is to double up the quote characters, so you need:
"This ""word"" is in quotes"
That looks a bit odd if the quotes come at the end of the string, because
you end up with 3 in a row:
"This ""word"""
So you need:
QueryCriteria = "Like ""camera*"""
Or, if the search word is in the text box named Text0:
QueryCriteria = "Like """ & [Text0] & "*"""
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<mi*********@gmail.com> wrote in message
news:11********************@g10g2000cwb.googlegrou ps.com...
I have written a short function to pass different criteria to a query.
When I use the Like operator the string is inerpreted with single
quotes i.e
QueryCriteria = "Like '" & "camera*" & "'"
is inerpreted in the query as
Like 'camera*'
The query fails to run as the query is expecting Like "camera*"
Any sugestions as to the correct syntax would be appreciated.