如何避免警报 "You won't be able to undo the changes this action query is about to make to the data in a linked table or tables"

How to avoid alert "You won't be able to undo the changes this action query is about to make to the data in a linked table or tables"

我写了一段代码来调用 Access 表单中单击按钮时的模块,当我单击 d 按钮时,我收到以下警报:

"You won't be able to undo the changes this action query is about to make to the data in a linked table or tables"

"You are about to update X row(s)"。

按钮后面的代码是:

Private Sub UpdateRS_Click()
    Call UpdateModul.Update
End Sub

模块是:

Public Function Update()
DoCmd.RunSQL "Update tbl03 INNER JOIN tblMaster " & _
 "ON tbl03.KW = tblOnd_RS.KW " & _
 "SET tbl03.CAp = [tblMaster].[CAp] "
End Function

如何避免这些警告信息?感谢您的帮助。

参见http://www.fmsinc.com/microsoftaccess/query/action-queries/SuppressWarningMessages.htm and http://www.utteraccess.com/wiki/index.php/RunSQL_vs_Execute

你可以使用

DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE ..."
DoCmd.SetWarnings True

但这有很多问题,例如一个错误可能会阻止 DoCmd.SetWarnings True 从 运行,然后可能导致灾难。

更好的是:

Dim db As DAO.Database
Set db = CurrentDb  
db.Execute "UPDATE ...", dbFailOnError