[英]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”
I wrote a code to call a module on the button click in Access form and when I click on d button, i recieve d following alerts:我编写了一个代码来调用 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" “您将无法撤消此操作查询即将对链接表中的数据进行的更改”
and和
"You are about to update X row(s)". “您即将更新 X 行”。
The code behind the button is:按钮背后的代码是:
Private Sub UpdateRS_Click()
Call UpdateModul.Update
End Sub
And module is:模块是:
Public Function Update()
DoCmd.RunSQL "Update tbl03 INNER JOIN tblMaster " & _
"ON tbl03.KW = tblOnd_RS.KW " & _
"SET tbl03.CAp = [tblMaster].[CAp] "
End Function
How to avoid these alert messages?如何避免这些警报消息? I appreciate any help.我很感激任何帮助。
See http://www.fmsinc.com/microsoftaccess/query/action-queries/SuppressWarningMessages.htm and http://www.utteraccess.com/wiki/index.php/RunSQL_vs_Execute .请参阅http://www.fmsinc.com/microsoftaccess/query/action-queries/SuppressWarningMessages.htm和http://www.utteraccess.com/wiki/index.php/RunSQL_vs_Execute 。
You could use你可以用
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE ..."
DoCmd.SetWarnings True
but this has multiple problems, eg an error could prevent DoCmd.SetWarnings True
from running, which then could lead to disaster.但这有多个问题,例如错误可能会阻止DoCmd.SetWarnings True
运行,从而导致灾难。
Much better is:更好的是:
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "UPDATE ...", dbFailOnError
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.