[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

RunSQL and Apostoph problem

Hi,

I have a RunSQL statement in my code like this:

DoCmd.RunSQL "INSERT INTO MyTable SET MyField='" & MyValue & "';"

If MyValue is ...

"It's raining."

Then I get the problem of the extra ' (apostroph) in the string MyValue. Same in WHERE clauses.

What is the solution for this problem?
How can I change the SQL statements?

Thanks ...

BL
0
beni_luedi
Asked:
beni_luedi
1 Solution
 
nico5038Commented:
Just use the chr(34) to embed the double qoute in the string:

DoCmd.RunSQL "INSERT INTO MyTable SET MyField=" & chr(34) & MyValue & chr(34) & ";"

Nic;o)
0
 
beni_luediAuthor Commented:
Like always ... fast and the exact answer. Thanks a lot.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now