Calling a function in a Subform

  • Thread starter Thread starter ZenoParadox
  • Start date Start date
Z

ZenoParadox

Let's say I have form called MyForm which has a button called MyButto
and a subform called MySubForm. The SubForm's name is FormSubForm an
it has a function in its code called MySubFormFunction.

How can I trigger MySubFormFunction by clicking MyButton on MyForm?


In this particular instance, I'm actually using the subform to load
large image into an Image control (I want it in a subform so that I ca
use the scroll bars -- if there's another way to make a scrollabl
image without custom controls I'd love to know it). I don't want it t
try and load the image though until my main form has provided th
correct filename and the user has said to load it. But I can't seem t
trigger a foreign subform's function (in this case, to load the imag
file from a given URL) from my main form.

I could probably do a jury-rigged approach where I have a hidden Tex
control on the subform that I change the contents of from the mai
form, and then use the Change event to trigger the function... but tha
seems really sloppy and potentially error prone. There's got to be
way to do this properly... help
 
Gah! I mucked around long enough and figured out. (Thank you, Objec
Browser!)

The format is:

Form_FormSubForm.MySubFormFunction

Where MySubFormFunction is a Public Sub (in this case -- I imagine
Public Function would work the same; maybe even a Private one?).

I was getting an error which I thought was because of that line, but i
turned out the error was in the function itself (in the subform) but i
triggering on the line in the parent form
 
ZenoParadox said:
Gah! I mucked around long enough and figured out. (Thank you, Object
Browser!)

The format is:

Form_FormSubForm.MySubFormFunction

Where MySubFormFunction is a Public Sub (in this case -- I imagine a
Public Function would work the same; maybe even a Private one?).
Since that kind of reference doesn't specify the instance of
the form object, it may be ambiguous. Better to use:

Me.subformcontrol.Form.MySubFormFunction

to specify exactly which instance of the object the
procedure should execute in.

And No, a private function should not be recognized outside
the form's module. The concept here is that Public
procedures in class modules (including form modules) are
methods of the class and are referenced just like the
built-in methods: object.method
 
Back
Top