Referring to "parent" form from "child"

M

Max Moor

Hi All,

I have a form who's code opens a second form. This "child" form
edits some data I'd like to write back to a control on the "parent" form.

Is there a way to refer to a control on the parent form, without
using that form's name? If so, I could open the same child, and accomplish
this task, from multiple parent forms.

Thanks, Max
 
R

Rick Brandt

Max Moor said:
Hi All,

I have a form who's code opens a second form. This "child" form
edits some data I'd like to write back to a control on the "parent" form.

Is there a way to refer to a control on the parent form, without
using that form's name? If so, I could open the same child, and accomplish
this task, from multiple parent forms.

Include the name of the calling form in the OpenArgs argument. This can be
referred to in the second form uniformly to always write back to the form that
opened it.
 
A

Adrian Jansen

I thought you could also just use the Parent property too:

Me.Parent.myTextbox = whatever

of course you still have to know the name of the control on the parent, so
its not all that useful.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
D

Dan Artuso

Hi,
Use the OpenArgs argument of the OpenForm method to pass the
name of your form to the child form.

Check out OpenArgs in Help.

It would be something like this:
DoCmd.OpenForm "childForm",,,,,,Me.Name
 
T

TC

Just have each calling form pass its name (Me.Name) in the argument
parameter of the OpenForm call. Then, the called form can get that value
from its OpenArgs property. Then it can refer to a control on the calling
form, like this:

forms(me.openargs)![xxx]

where xxx is the control name.

HTH,
TC
 
T

TC

Adrian Jansen said:
I thought you could also just use the Parent property too:

Me.Parent.myTextbox = whatever

No, Parent is only for a mainform/subform situation. It does not apply when
a form calls another form with OpenForm.

TC
 

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