Syntax error when using comma and apostraphe

violentjay25

Registered User.
Local time
Today, 17:11
Joined
Feb 22, 2005
Messages
30
I have a question. I am using Access as a frontend and the backend is a SQL server. I have used the code below in order to put more that 256 characthers into the txtMemo1 field. This was the only way I could get it to work. The problem occurs when on the form if you use a comma or apostraphe I receive a runtime error. I know this is because acces thinks its code. Its not a huge deal but is there anyway to elimiate this problem. Here is the code



Private Sub cmdUpdate_Click()

DoCmd.RunSQL "Insert into tbl_Updates (Date1, Memo1, ProjectName) " & _
"Values (#" & Me.txtDate1 & "#, '" & _
Me.txtMemo1 & "', '" & _
Me.cboProjectName & "')"
 
You should use quotes (") instead of apostrophes (').
 
vj,

Code:
DoCmd.RunSQL "Insert into tbl_Updates (Date1, Memo1, ProjectName) " & _
              "Values (#" & Me.txtDate1 & "#, """ & _
                            Me.txtMemo1 & """, '" & _
                            Me.cboProjectName & "')"

Wayne
 

Users who are viewing this thread

Back
Top Bottom