How do I call a sub in one form module from a sub in another form.

R

Rod

I have a form with two subforms. A button on the first subform executes a
sub in that subform which opens the second subform. For reasons it is not
necessary to bore one with here, upon completing and saving entries on the
second subform, I would like to "re-open" it by calling, from the second
subform, the sub in the first subform that initially opened the second
subform. I'll slightly bore you by stating that opening the second subform
as I do performs an initialization that only works when I open the second
subform from the first subform. The problem is, when attempting to call or
run the sub in the first subform module from the sub in the second subform
module, I cannot get Access to recognize the sub in the first subform module
.. Help.
 
M

Marshall Barton

Rod said:
I have a form with two subforms. A button on the first subform executes a
sub in that subform which opens the second subform. For reasons it is not
necessary to bore one with here, upon completing and saving entries on the
second subform, I would like to "re-open" it by calling, from the second
subform, the sub in the first subform that initially opened the second
subform. I'll slightly bore you by stating that opening the second subform
as I do performs an initialization that only works when I open the second
subform from the first subform. The problem is, when attempting to call or
run the sub in the first subform module from the sub in the second subform
module, I cannot get Access to recognize the sub in the first subform module


This is too convoluted. It is not necessary to (re)open the
second form. (Note: you can not open a subform, so you must
be talking about separate forms.) The (re)initialization of
the second form can be done entirely from within itself by
rearranging the code into an appropriate set of procedures
(even if you need argument values from the first form).

Why don't you tell use what form two is trying to accomplish
and I'll bet someone will be able to help you straighten
this out.

BTW, you can call a PUBLIC procedure in another form by
using the syntax: Forms!otherform.procedurename

Another thouught. If the first form opens the second form
in Dialog mode, the code in the first form is suspended
until the second form is closed (or becomes invisible).
This means the second form only needs to close itself, at
which point the code in the first form resumes and can, if
desired, open the second subform again. But this still
sounds like a little too much cross dependency between the
forms.
 

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