Call Public Sub in a SubForm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Master Form with multiple subforms. I want to call a Public (I
changed it from Private to Public) subroutine from a different Subform which
is part of the same Master form. It doesn't work.

Here is my call:
Forms!frmMaster!frmChecks.Post_Check

I am calling Public Sub Post_Check() from a subroutine in
Forms!frmMaster!frmPost

The Message is:
RunTime Error '438'
Object doesn't support this Property or Method

What am I missing?

Many Thanks

Ross
 
Ross,

I generally find that if I want to call code that is in a forms code module,
from another form, that it really belongs in a code module, rather than in
the forms code module.

This can cause some challenges, because you can no longer refer to the form
as Me, but this is relatively easy to overcome by passing the form or the
form name to the code module.

HTH
Dale
 
Dale,

I agree. I did this subform business as a "afterthought" (after devloping
the individual forms). I can transfer all the code to a class module, but
was hoping that I didn't have to do this.

Thank You!
 
Dale did not say Class module.
There is a big difference between a Standard "Code" module and a Class
module. A standard module is a collection of mostly Public subs and functions
that can be called from any where in the application. They will sometimes
contain Private procedures if the private procedures are used only by other
procedures in the same module.
A Class module is a very different thing. Class modules are a special kind
of module that has methods and properties. You create an instance of a Class
with a name, then use the properties an methods.
 
Ross said:
I have a Master Form with multiple subforms. I want to call a Public
(I changed it from Private to Public) subroutine from a different
Subform which is part of the same Master form. It doesn't work.

Here is my call:
Forms!frmMaster!frmChecks.Post_Check

I am calling Public Sub Post_Check() from a subroutine in
Forms!frmMaster!frmPost

The Message is:
RunTime Error '438'
Object doesn't support this Property or Method

What am I missing?

Many Thanks

Ross

Quite possibly the Form keyword

Forms!frmMaster!frmChecks.Form.Post_Check
 
And if not that, try adding 'Call':

Call Forms!frmMaster!frmChecks.Form.Post_Check

HTH,
 
Back
Top