VBA UPDATE查询。将NULL字段设置为值

时间:2014-01-21 15:06:12

标签: vba updates

我正在尝试为以下操作运行更新命令: 在名为 t_AuditCompliance_import 的表格中 如果名为“Payable Time Entered By”的字段为空,请将NULL更新为“exception”。

DoCmd.RunSQL "UPDATE t_AuditCompliance_import SET t_AuditCompliance_import.[Payable Time Entered By] = ("exception")" _
         & "WHERE (((t_AuditCompliance_import.[Payable Time Entered By]Is Null));"

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:1)

请尝试以下操作:

DoCmd.RunSQL "UPDATE t_AuditCompliance_import SET t_AuditCompliance_import.[Payable Time Entered By] = ""exception"" " _
     & "WHERE (((t_AuditCompliance_import.[Payable Time Entered By] Is Null));"

答案 1 :(得分:0)

在]和Is之间没有空格,而且在WHERE子句的开头需要一个空格。应该是

DoCmd.RunSQL "UPDATE t_AuditCompliance_import SET t_AuditCompliance_import.[Payable Time Entered By] = ("exception")" _
& " WHERE (((t_AuditCompliance_import.[Payable Time Entered By] Is Null));"