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
when c is pressed it trigger A and B buttons as well in MS Access 2010?
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
when c is pressed it trigger A and B buttons as well in MS Access 2010?
With little trick ..
In your Btn C Click event
btnA.SetFocus
Call SendKeys(" ",True)
btnB.SetFocus
Call SendKeys(" ",True)
As noticed already, you can simply 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?
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
To start, your Click procedure needs to be Public rather than Private. Then the following syntax will work:
Call Forms.frmForm1.button1_Click
Using your FormName and ControlName of course!