Call a subform procedure from parent form

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

How can I call a subform's procedure from a parent form?

I have a control with varying subforms, so I want the parent to only have to
know a procedure name that all the subforms will contain (but have different
contents).
 
Remove the Private keyword form the subform's procedure declaration, and try
something like this in the main form's module:
Call Me.[NameOfYourSubformControlHere].Form.MyControl_Click
 
Chris said:
How can I call a subform's procedure from a parent form?

I have a control with varying subforms, so I want the parent to only have to
know a procedure name that all the subforms will contain (but have different
contents).


Me.subformcontrolname.FORM.procedurename
 
Chris,

Here's one way, using your control's BeforeUpdate event as the procedure you
want to execute:

Dim ctl As Control

Set ctl = YourControl

CallByName ctl.Parent, ctl.Name & "_BeforeUpdate", VbMethod, False

Any parameters that are required by the procedure are passed at the end and
are separated by commas. In the above example, only a single parameter,
"False", is passed.
 
Back
Top