HELP: Pressing Buttons in SubForm from a Main Form

M

Michael Kintner

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
 
K

Klatuu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top