Question about '

  • Thread starter Thread starter Elecer B.
  • Start date Start date
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.
 
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
 
Try:

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

HTH
Van T. Dinh
MVP (Access)
 
Back
Top