vba 如何关闭(卸载)表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26452849/
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
How to close (unload) a form
提问by mans
I have a form that has some buttons, and when user click on a button, the form should be closed (unloaded). I used the following methods, but all generate error:
我有一个带有一些按钮的表单,当用户单击一个按钮时,该表单应该关闭(卸载)。我使用了以下方法,但都产生错误:
docmd.close me
unload me
What is the best way to close or unload a form in VBA (from code inside the form)
在 VBA 中关闭或卸载表单的最佳方法是什么(来自表单内的代码)
回答by HansUp
DoCmd.Closeexpects ObjectTypeas its first argument, followed by ObjectNamewhich is a variant string as the object name.
DoCmd.Close期望ObjectType作为它的第一个参数,然后是ObjectName,它是一个变体字符串作为对象名称。
So in the click event of a command button which is intended to close the current form, I use this ...
因此,在用于关闭当前表单的命令按钮的单击事件中,我使用了这个......
DoCmd.Close acForm, Me.Name

