我总是在日期'#10.08.2017 15:27:16'中得到运行时错误3075:语法错误。我的代码如下所示:
Dim ActID As Integer
ActID = Me!Of_ID
DoCmd.RunSQL "UPDATE BD_Offer SET BD_Offer.Of_Timestamp = #" & Format(Now, "DD.MM.YYYY HH:NN:SS") & "# WHERE BD_Offer.Of_ID = '" & ActID & "';"
当我改变#" &安培;格式& "#引用'" &安培;格式& "'
DoCmd.RunSQL "UPDATE BD_Offer SET BD_Offer.Of_Timestamp = '" & Format(Now, "DD.MM.YYYY HH:NN:SS") & "' WHERE BD_Offer.Of_ID = '" & ActID & "';"
然后我得到运行时错误3464:Dataconflict。
Of_Timestamp具有Datetyp,Of_ID自动填充整数作为主键。
感谢您的回复
卢卡
答案 0 :(得分:2)
使用有效格式:
BD_Offer.Of_Timestamp = #" & Format(Now, "yyyy\/mm\/dd hh\:nn\:ss") & "#
当Of_ID是自动编号时,您还必须提供数字参数:
"UPDATE BD_Offer SET BD_Offer.Of_Timestamp = #" & Format(Now, "yyyy\/mm\/dd hh\:nn\:ss") & "# WHERE BD_Offer.Of_ID = " & ActID & ";"
但是,你可能只是逃避:
"UPDATE BD_Offer SET BD_Offer.Of_Timestamp = Now() WHERE BD_Offer.Of_ID = " & ActID & ";"