Calling Procedure in Hidden Form

S

Stu

What is the syntax for calling an event procedure in a hidden form from a
visible (current) form?

My hidden form has two procedures: form_open and Closebutton_click. I
assume when I open the hidden form the form_open procedure is run. I want to
run the Closebutton_click procedure in the hidden form when a certain event
occurs on the visible (current) form. The CloseButton_click will run some
code and then close the hidden form.
 
T

Tom van Stiphout

On Wed, 7 Apr 2010 06:26:06 -0700, Stu <[email protected]>
wrote:

You can make that procedure Public rather than the current Private.

But much better is to move that code to the Form_Close event so it
runs regardless of how the form is closed. Then in the other form you
can simply use:
DoCmd.Close acForm, "myOtherFormName"

-Tom.
Microsoft Access MVP
 
M

Marshall Barton

Stu said:
What is the syntax for calling an event procedure in a hidden form from a
visible (current) form?

My hidden form has two procedures: form_open and Closebutton_click. I
assume when I open the hidden form the form_open procedure is run. I want to
run the Closebutton_click procedure in the hidden form when a certain event
occurs on the visible (current) form. The CloseButton_click will run some
code and then close the hidden form.


Make sure the button's Click event procedure is Public.
Then you can use either:

Forms![hidden form].Closebutton_click
or
Call Forms![hidden form].Closebutton_click()
 
S

Stu

Got it. Thanks Marshall

Marshall Barton said:
Stu said:
What is the syntax for calling an event procedure in a hidden form from a
visible (current) form?

My hidden form has two procedures: form_open and Closebutton_click. I
assume when I open the hidden form the form_open procedure is run. I want to
run the Closebutton_click procedure in the hidden form when a certain event
occurs on the visible (current) form. The CloseButton_click will run some
code and then close the hidden form.


Make sure the button's Click event procedure is Public.
Then you can use either:

Forms![hidden form].Closebutton_click
or
Call Forms![hidden form].Closebutton_click()
 
F

fredg

What is the syntax for calling an event procedure in a hidden form from a
visible (current) form?

My hidden form has two procedures: form_open and Closebutton_click. I
assume when I open the hidden form the form_open procedure is run. I want to
run the Closebutton_click procedure in the hidden form when a certain event
occurs on the visible (current) form. The CloseButton_click will run some
code and then close the hidden form.

Make sure the sub procedure is set to Public (instead of Private).
Both forms must be open.

To call it from another form:
Call Forms("FormName"). CloseButton_Click

To call a sub procedure on a sub form, use:

Call Forms("FormName").SubformControlName.Form. CloseButton_Click

Substitute the actual name of your main form where it says "FormName".
Substitute the actual name of the subform control on the main form
which holds the sub form (not the name of the form used as the
subform) where it says "SubformControlName".
 

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