Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call main form event from subform

Status
Not open for further replies.

HomeGrowth

Technical User
Aug 19, 2004
76
0
0
US
My AfterUpdate event in subform, I want to call the OnCurrent event on Main Form. I tried these codes

Call Forms![MainForm].OnCurrent

or

Call Forms.[MainForm].Form.OnCurren

obviously, I am not doing right. any suggestions? Thanks
 
Make the event procedure Public instead of Private and then:
Call Forms![MainForm].Form.Form_Current()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
how about

Code:
me.parent.Form_Current
I think it has to be decleared as public
 
I personally would not do it that way because it limits the useability of the subform. Now that subform has to be used within the main form. Instead I always simply trap the sub form event in the main form, and do not write any code in the subform

Code:
Public WithEvents subFrm As Access.Form

Private Sub Form_Load()
  Set subFrm = Me.subFrmCtl.Form
End Sub

Private Sub subFrm_AfterUpdate()
  MsgBox "sub form after update event trapped in main form"
End Sub

Need to make sure the subform has a module and that the after update of the subform has "[Event Procedure]" selected.
 
You are amazing. The code did work after the I declare the event as Public.

I also tested out MajP's suggestion. It works great.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top