Call a subform procedure from parent form

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).
 
A

Allen Browne

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
 
M

Marshall Barton

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
 
M

MikeC

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.
 

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