I'm getting a syntax error in my UPDATE statement, but I'm not sure where exactly it is. Here's my code:
我在UPDATE语句中遇到语法错误,但我不确定它到底在哪里。这是我的代码:
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
1 个解决方案
#1
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.
这很可能是因为Now()函数,它还打印当前时间(用空格分隔) - 因此语法错误。尝试用单引号将它们包围起来。
You can also print out the SQL Statement Debug.Print strSelected
to see what you have concatenated...
您还可以打印出SQL语句Debug.Print strSelected以查看您连接的内容...
#1
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.
这很可能是因为Now()函数,它还打印当前时间(用空格分隔) - 因此语法错误。尝试用单引号将它们包围起来。
You can also print out the SQL Statement Debug.Print strSelected
to see what you have concatenated...
您还可以打印出SQL语句Debug.Print strSelected以查看您连接的内容...