vba 从访问中的另一个按钮调用一个按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17564617/
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
To call a button from another button in access
提问by CrashOverride
I am trying to call a button from another button in access via event procedure any suggestion how to achieve this?
我正在尝试通过事件过程从另一个按钮调用一个按钮,有什么建议可以实现这一点吗?
For e.g i have three buttons a b and c. so
例如,我有三个按钮 ab 和 c。所以
when c is pressed it trigger A and B buttons as well in MS Access 2010?
当按下 c 时,它会在 MS Access 2010 中触发 A 和 B 按钮吗?
回答by matzone
With little trick ..
小技巧..
In your Btn C Click event
在您的 Btn C Click 事件中
btnA.SetFocus
Call SendKeys(" ",True)
btnB.SetFocus
Call SendKeys(" ",True)
回答by LS_???
As noticed already, you can simply Call from.button_Click
.
正如已经注意到的,您可以简单地Call from.button_Click
.
However, maybe you should modularize your code. If button C also triggers functionality from button A and B, why not create functions for shared code and call them?
但是,也许您应该模块化您的代码。如果按钮 C 也从按钮 A 和 B 触发功能,为什么不为共享代码创建函数并调用它们?
Code in same form, module, other form, wherever it makes more sense:
相同形式、模块、其他形式的代码,只要更有意义:
Public Function funcA()
'... (Shared code from button A)
End Function
Public Function funcB()
'... (Shared code from button B)
End Function
Code in form:
代码形式:
Private Sub ButtonA_Click()
Call funcA
End Sub
Private Sub ButtonB_Click()
Call funcB
End Sub
Private Sub ButtonC_Click()
'... (Specific code from button C)
Call funcA
Call funcB
End Sub