Referring to "parent" form from "child"

  • Thread starter Thread starter Max Moor
  • Start date Start date
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
 
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.
 
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
 
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
 
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
 
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
 
Back
Top