我正在尝试更新包含Null值的列。我以为波纹管代码可以工作,但由于查询表达式中缺少运算符而出现语法错误。我似乎无法弄清楚。有什么帮助吗?
Private sub dataUpdate_Click()
Dim SQL As String
On Error GoTo cancelledClicked
SQL = "UPDATE table1 " & _
"SET [Column1] = 1 WHERE [Column1] IS NULL " & _
"SET [Column2] = 0 WHERE [Column2] IS NULL; "
DoCmd.RunSQL SQL
exitDataUpdate:
Exit Sub
ignoreError:
MsgBox Err.Description
Exit Sub
cancelledClicked:
If Err.Number = 2501 Then GoTo exitDataUpdate
If Err.Number <> 2501 Then GoTo ignoreError
Resume Next
End sub
答案 0 :(得分:2)
这是您想要的逻辑吗?
UPDATE table1
SET [Column1] = NZ([Column1], 1),
[Column2] = NZ([Column2], 0)
WHERE [Column1] IS NULL OR [Column2] IS NULL
您的代码有语法错误。