Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

RunSQL and Apostoph problem

Posted on 2002-05-26
2
Medium Priority
?
260 Views
Last Modified: 2012-05-04
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
Comment
Question by:beni_luedi
2 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 400 total points
ID: 7036428
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
 

Author Comment

by:beni_luedi
ID: 7036563
Like always ... fast and the exact answer. Thanks a lot.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question