A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

HELP: Pressing Buttons in SubForm from a Main Form



 
 
Thread Tools Display Modes
  #1  
Old April 24th, 2008, 02:44 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding
Michael Kintner[_2_]
external usenet poster
 
Posts: 28
Default 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  
Old April 24th, 2008, 03:10 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access
Klatuu
external usenet poster
 
Posts: 7,074
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.