1

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?

4

3 回答 3

2

With little trick ..

In your Btn C Click event

  btnA.SetFocus
  Call SendKeys(" ",True)
  btnB.SetFocus
  Call SendKeys(" ",True)
于 2013-07-10T07:30:27.633 回答
1

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
于 2013-07-10T08:04:21.283 回答
0

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!

Source :

于 2013-07-10T07:37:03.423 回答