If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
HELP: Pressing Buttons in SubForm from a Main Form
I have a main form with two sub forms within the Main. When I press a
button in the main form I would like it to also press a button in the sub forms. How to I call the sub form button to execute from within the Main form? frmMain has button butProcessRec subFrmA within frmMain has button butAddRecA subFrmB within frmMain has button butAddRecB ' ' Code in frmMain trying to press a button in the subform ' Private Sub butProcessRec_Click() ' Press button in subFrmA within frmMain called subFrmA.butAddRecA_Click() ??? ' Press button in subFrmB within frmMain called subFrmB.butAddRecB_Click() ??? End Sub Thank you in advance for your help! Mike |
#2
|
|||
|
|||
HELP: Pressing Buttons in SubForm from a Main Form
The problem is that the Click event of a command button is a Private Sub and
therefore the main form can't see it. I would recommend you just duplicate the code for the buttons in the sub form in the main form's button to do the work. Now, the syntax to address objects in a subform form a main form is: Me.SubFormControlName.Form!ControlName Note that SubFormControlName is the name of the subform control, not the name of the form being used as a subform -- Dave Hargis, Microsoft Access MVP "Michael Kintner" wrote: I have a main form with two sub forms within the Main. When I press a button in the main form I would like it to also press a button in the sub forms. How to I call the sub form button to execute from within the Main form? frmMain has button butProcessRec subFrmA within frmMain has button butAddRecA subFrmB within frmMain has button butAddRecB ' ' Code in frmMain trying to press a button in the subform ' Private Sub butProcessRec_Click() ' Press button in subFrmA within frmMain called subFrmA.butAddRecA_Click() ??? ' Press button in subFrmB within frmMain called subFrmB.butAddRecB_Click() ??? End Sub Thank you in advance for your help! Mike |
Thread Tools | |
Display Modes | |
|
|