我正在尝试更新包含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
这是你想要的逻辑吗?
UPDATE table1
SET [Column1] = NZ([Column1], 1),
[Column2] = NZ([Column2], 0)
WHERE [Column1] IS NULL OR [Column2] IS NULL
您的代码有语法错误。