Access quivalent of \'

  • Thread starter Thread starter Charles
  • Start date Start date
C

Charles

Hello

Small problem. I have some txt fields which can contain both some '
and some ". In MySQL, the way to neutralize a ' or a " in a query was
to place a \ before. Is there anything equivalent in Access? Or
alternatively, how should I create in VBA an sql string that says

sql="SELECT * FROM tbl WHERE tbl.name LIKE 'ooo'"

with ooo being a string, say: The'String"with'Annoying"Characters

Thanks in advance
Charles
 
Thanks but that's not exactly solving the problem. The
The'String"with'Annoying"Characters already exists and is stored in a
database, so I am not trying to create it. I have it already stored in
a variable xxx as string, and I would like to do something like:

sql="SELECT * FROM tbl WHERE tbl.name LIKE '" & xxx & "';"

The problem is that it creates the following string:

sql="SELECT * FROM tbl WHERE tbl.name LIKE
'The'String"with'Annoying"Characters ';"

and access gets confused with the ' after "The". I know the solution
in MySql is to do a simple replace to get:

sql="SELECT * FROM tbl WHERE tbl.name LIKE 'The\'String\"with\'Annoying
\"Characters ';"

But that doesn't seem to work in Access. Any idea?

thanks
Charles
 
SQL Server has an ESCAPE argument after the LIKE clause

This should almost suit your needs perfectly

-Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top