Call Function

  • Thread starter Thread starter Abe Katz
  • Start date Start date
A

Abe Katz

Hello All,
I have an event function on a Command button on a main form.
I want to call the procedure from the sub form, but it doesn't work.
i.e. Call Command_Button_Click().
I even changed it to a Public function.
Thanks in advance
 
Abe Katz said:
Hello All,
I have an event function on a Command button on a main form.
I want to call the procedure from the sub form, but it doesn't work.
i.e. Call Command_Button_Click().
I even changed it to a Public function.
Thanks in advance


If the procedure is on the main form, and you want to call it from a
subform, you need to prefix the call with a reference to the parent form,
like this:

Call Me.Parent.Command_Button_Click

That should work, provided that the procedure has been made Public.
 
Dirk Goldgar said:
If the procedure is on the main form, and you want to call it from a
subform, you need to prefix the call with a reference to the parent form,
like this:

Call Me.Parent.Command_Button_Click

That should work, provided that the procedure has been made Public.

Why would it have to be Public if you are walking the object tree?
 
MikeB said:
Why would it have to be Public if you are walking the object tree?

By default, events are Private. That means that they can only be called from
within the class module in which they're defined. Since you're trying to
call from a different module (i.e.: the class module associated with the
subform), it won't work unless it's public.
 
Back
Top