vba 在访问中禁用 msgbox

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/669520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:17:58  来源:igfitidea点击:

Disabling msgbox in access

vbams-accessaccess-vba

提问by THEn

I am trying to make a small form in MS Access 2003 SP3, I use some function that some other people made and these function has msgbox in it. I would like to disable msgbox while I am running the form. Is it possible in Access to disable msgbox?

我正在尝试在 MS Access 2003 SP3 中制作一个小表单,我使用了一些其他人制作的功能,并且这些功能中包含 msgbox。我想在运行表单时禁用 msgbox。是否可以在 Access 中禁用 msgbox?

采纳答案by THEn

I created my finction called msgbox. Seems like its working. Thanks everyone for your help.

我创建了名为 msgbox 的功能。似乎它的工作。感谢大家的帮助。

Public Function MsgBox(Prompt, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title, Optional HelpFile, Optional Context) As VbMsgBoxResult

If myProcedureisRunning then 
    VBA.MsgBox Prompt
else
    debug.print prompt
endif
End Function

回答by HardCode

If in fact these message boxes are produced from VBA code, then comment them out. However, if they are Access generated, such as the message box when inserting or updating records, you need to use the command DoCmd.SetWarnings Falsein order to suppress them. Just make sure to turn warnings off only when needed, then turn them back on. Otherwise, ALL message boxes from Access will be off, even in "design mode".

如果这些消息框实际上是由 VBA 代码生成的,则将它们注释掉。但是,如果它们是Access生成的,例如插入或更新记录时的消息框,则需要使用命令DoCmd.SetWarnings False才能抑制它们。只需确保仅在需要时关闭警告,然后重新打开它们。否则,来自 Access 的所有消息框都将关闭,即使在“设计模式”中也是如此。

回答by user46795

Do a CTRL-F and find for MSGBOX and comment it. I guess that's the only way you can do it.

执行 CTRL-F 并找到 MSGBOX 并对其进行评论。我想这是你能做到的唯一方法。

回答by Lunatik

Press Alt+F11 to open the Visual Basic IDE, then press CTRL+F to search. Type

按 Alt+F11 打开 Visual Basic IDE,然后按 CTRL+F 进行搜索。类型

msgbox
进入查找,选择“替换”并键入
'msgbox
进入“替换为”框(注意撇号)。这将注释掉项目中的所有 msgbox 语句。