Syntax Error in SQL expression (1 Viewer)

DB_Queen

New member
Local time
Today, 19:43
Joined
Sep 20, 2021
Messages
22
Hello experts,

I'm attempting to update a record in a table by running a quick SQL statement behind a button a user clicks on a form. For some reason, I'm getting a "syntax error in criteria expression" error on the below. It looks perfectly normal to me and I am stumped as to why I'm getting this error. Any ideas?

DoCmd.RunSQL "UPDATE TABLENAME " _
& "SET FIELDNAME = '" & Me.COMBOBOX & "', FIELDNAME2= False, FIELDNAME3 = "" WHERE TABLENAME.ID = " & Me.txtID & ""
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:43
Joined
Oct 29, 2018
Messages
21,358
Copy and paste the SQL in the query designer to get a hint on the problem from Access.
 

DB_Queen

New member
Local time
Today, 19:43
Joined
Sep 20, 2021
Messages
22
Hi,

I have already tried that, and nothing jumped out at me as an obvious issue 🤷‍♀️
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:43
Joined
Sep 21, 2011
Messages
14,048
Good practice to put it into a string variable and Debug.Print that as well?

Fieldname3= perhaps?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:43
Joined
Oct 29, 2018
Messages
21,358
Hi,

I have already tried that, and nothing jumped out at me as an obvious issue 🤷‍♀️
Access didn't throw an error message and highlight the problem area?
 

DB_Queen

New member
Local time
Today, 19:43
Joined
Sep 20, 2021
Messages
22
Hi,

Here is the specific message I'm getting. It has a problem with the record ID I'm passing.

1650644187679.png
 

DB_Queen

New member
Local time
Today, 19:43
Joined
Sep 20, 2021
Messages
22
As an update, changing the double quotes to single did the trick. Thank you :)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:43
Joined
Oct 29, 2018
Messages
21,358
As an update, changing the double quotes to single did the trick. Thank you :)
Excellent! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom