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.
 

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

Similar Threads

SQL Syntax Error 6
Error 3075 Missing Operator 7
Syntax (Missing Operator) in Query Expr .... 2
Help with syntax error 1
Duane Hookum's Recurring DB example 0
Syntax Error 8
Syntax Error 2
sql syntax error 3

Back
Top