SQL Syntax Error

  • Thread starter Thread starter kenrav
  • Start date Start date
K

kenrav

Anybody know why I'm getting a syntax error for the following code?

strSQL = "INSERT INTO dbo_tblTrans (PatientID, PatientName, Note, Username,
TransType, GUID) VALUES ('" & strPatID & "', '" & strPatName & "', '" &
varNote & "', '" & strUserName & "', 'Clinical Note', '" & sGUID & "')"

Thanks.
 
kenrav said:
Anybody know why I'm getting a syntax error for the following code?

strSQL = "INSERT INTO dbo_tblTrans (PatientID, PatientName, Note,
Username,
TransType, GUID) VALUES ('" & strPatID & "', '" & strPatName & "', '" &
varNote & "', '" & strUserName & "', 'Clinical Note', '" & sGUID & "')"


Is it a VBA syntax error you're getting, or a SQL syntax error? If the
former, is the original code really broken onto three lines, as it came out
in your post? In that case, you need a continuation character (_), after a
space, at the end of each of the first two lines.

If it's a SQL syntax error, what is the final value of strSQL as executed?
 
Dirk,

Thanks for your help. It's a SQL error (3134) - the code simply came out in
post this way.

I've now determined that using the field name 'GUID' is the issue. If I
call it something else, e.g. "xGUID" it works fine. GUID must be a reserved
word or something.
 
Back
Top