运行时错误3144 [英] Runtime error 3144
问题描述
我正在使用此代码,一旦运行它,我会收到运行时错误3144 .我不知道代码中的哪些地方需要更改或不正确.您能帮我解决这个问题吗?
I am using this code and once I run it I get runtime error 3144. I don't know where in the code needs to be changed or is not correct. Can you please help me to fix it?
CurrentDb.Execute "UPDATE WORKED_HOURS " & _
" set EMPLOYEE_ID=" & `enter code here`Me.cboEmployeeID & _
", SET FIRST_NAME='" & Me.FIRST_NAME & "'" & _
", SET LAST_NAME='" & Me.LAST_NAME & "'" & _
", Set WORK_ORDER_NO='" & Me.cboWorkOrderNo & "'" & _
", SET PROJECT_TITLE='" & Me.txtProjectTitle & "'" & _
", SET WORKED_DATE='" & Me.txtWorkedDate & "'" & _
", SET TIME_STARTED='" & Me.txtTimeStarted & "'" & _
", SET TIME_FINISHED='" & Me.txtTimeFinished & "'" & _
", SET WEEK_ENDING='" & Me.txtWeekEnding & "'" & _
" where EMPLOYEE_ID=" & Me.cboEmployeeID.Tag
推荐答案
实际上,每个SQL方言中的更新语句都不允许使用多个SET命令,而只允许使用带有逗号分隔的多个表达式的命令.考虑这样做,并根据数据类型正确地加上引号( strings ),井号( dates )或什么都没有( integer ):>
Update statements in practically every SQL dialect does not allow multiple SET commands but only one with multiple expressions separated by commas. Consider doing so and enclosing properly according to data type with quotes (strings), pound signs (dates) or nothing (integer):
CurrentDb.Execute "UPDATE WORKED_HOURS " _
& " SET EMPLOYEE_ID=" & Me.cboEmployeeID _
& " , FIRST_NAME='" & Me.FIRST_NAME & "'" _
& " , LAST_NAME='" & Me.LAST_NAME & "'" _
& " , WORK_ORDER_NO='" & Me.cboWorkOrderNo & "'" _
& " , PROJECT_TITLE='" & Me.txtProjectTitle & "'" _
& " , WORKED_DATE=#" & Me.txtWorkedDate & "#" _
& " , TIME_STARTED=#" & Me.txtTimeStarted & "#" _
& " , TIME_FINISHED=#" & Me.txtTimeFinished & "#" _
& " , WEEK_ENDING=#" & Me.txtWeekEnding & "#" _
& " WHERE EMPLOYEE_ID=" & Me.cboEmployeeID.Tag
但是为了获得最佳实践,请考虑使用参数化的querydef,它甚至可以避免使用所需的引号或井号. Jet/ACE SQL允许使用PARAMETERS
子句声明参数.
But for best practices, consider a paramterized querydef which even avoids needed quotes or pound signs. Jet/ACE SQL allows parameter declaration with the PARAMETERS
clause.
Dim qdef As querydef
strSQL = "PARAMETERS [EMPLOYEE_ID] Integer, [FIRST_NAME] Text(255)," _
& " [LAST_NAME] Text(255), [WORK_ORDER_NO] Text(255)," _
& " [PROJECT_TITLE] Text(255), [WORKED_DATE] Datetime," _
& " [TIME_STARTED] Datetime, [TIME_FINISHED] Datetime," _
& " [WEEK_ENDING] Datetime;"
& " UPDATE WORKED_HOURS " _
& " SET EMPLOYEE_ID = [EMPLOYEE_ID]" _
& " , FIRST_NAME = [FIRST_NAME]" _
& " , LAST_NAME = [LAST_NAME] " _
& " , WORK_ORDER_NO = [WORK_ORDER_NO] " _
& " , PROJECT_TITLE = [PROJECT_TITLE]" _
& " , WORKED_DATE = [WORKED_DATE]" _
& " , TIME_STARTED = [TIME_STARTED]" _
& " , TIME_FINISHED = [TIME_FINISHED]" _
& " , WEEK_ENDING = [WEEK_ENDING]" _
& " WHERE EMPLOYEE_ID = [EMPLOYEE_ID]"
Set qdef = Currentdb.CreateQueryDef("", strSQL)
qdef!EMPLOYEE_ID = Me.cboEmployeeID
qdef!FIRST_NAME = Me.FIRST_NAME
qdef!LAST_NAME = Me.LAST_NAME
qdef!WORK_ORDER_NO = Me.cboWorkOrderNo
qdef!PROJECT_TITLE = Me.txtProjectTitle
qdef!WORKED_DATE = Me.txtWorkedDate
qdef!TIME_STARTED = Me.txtTimeStarted
qdef!TIME_FINISHED = Me.txtTimeFinished
qdef!WEEK_ENDING = Me.txtWeekEnding
qdef.Execute
Set qdef = Nothing
这篇关于运行时错误3144的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!