Solved

RunSQL and Apostoph problem

Posted on 2002-05-26
2
248 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 100 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restoring a form to its default settings 3 27
Normalization of a table 19 71
A Function to parse a text string 4 36
Any Way to Print an Import Spec? 3 29
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

770 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