Lilly
Lilly

Reputation: 233

syntax error in SQL Update statement

I'm getting a syntax error in my UPDATE statement, but I'm not sure where exactly it is. Here's my code:

    strSelected = "UPDATE CFRRR SET assignedby = " & Me.cmbassignedby.Column(1) & ", assignedto = " & _
                                  Me.cmbassignedto.Column(2) & ", Dateassigned = " & Now() & ", actiondate = " & _
                                  Now() & ", Workername = " & Me.cmbassignedto.Column(2) & ", WorkerID = " & _
                                  Me.cmbassignedto.Column(1) & " WHERE CFRRRID In ( " & strSelected & " );"
CurrentDb.Execute strSelected

Upvotes: 0

Views: 57

Answers (1)

Peter Schneider
Peter Schneider

Reputation: 2929

It's most likely because of the Now() function, which also prints the current time (seperated with a space) - hence the syntax error. Try to surround them with single quotation marks.

You can also print out the SQL Statement Debug.Print strSelected to see what you have concatenated...

Upvotes: 1

Related Questions