Question about '

E

Elecer B.

Hi,
I got error when input any data with quotation mark.
In my case, I am inputting data by a VBA coded form.
But error number 3075 is happen when my data contain any quotation mark.
There is my code:

Dim strReason As String
strReason = Me.Reason
...
.....
DoCmd.RunSQL "INSERT INTO RCNInfo ( Reason ) Values ( " & strReason &
" );"
...
..

That is a sample question, but it is hard to me.
Please, help me. Thanks

Elecer B.
 
T

Timothy C. Doherty

Single quote characters need to be represented by two single quotes, e.g.,
"don't"="don''t", "can't" = "can''t", etc... you could write a function to
parse your strReason variable and prepare the single quote characters
 
V

Van T. Dinh

Try:

DoCmd.RunSQL "INSERT INTO RCNInfo ( Reason ) Values ( " & _
Chr$(34) & strReason & Chr$(34) & " )"

HTH
Van T. Dinh
MVP (Access)
 

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

Top