Subform parent

  • Thread starter Thread starter DavidG
  • Start date Start date
D

DavidG

Hi,

I have a common subform used on 2 different forms.
I thought that using one subform would reduce code maintenance,
but now I'm not so sure :-)

Code on subform controls refers to controls on the MAIN form,
differently depending on the main form in use.

What is the best way to refer to the MAIN form from a subform control ?
I can't seem to get Me.Parent.Name to work as I want.

Or is this like "the road to Dublin"
and I shouldn't have started from here at all...

TIA

DavidG
 
No problem with reusing a subform if it really is a similar situation. If
you find yourself jumping through hoops to make it work, you'll know when 2
subforms would be the simpler solution.

What problem are you striking with Me.Parent.Name? Access loads the subform
first, so that reference might not be available if you checked really early
(during load) or really late (during closing), but other than that it should
work fine.
 
Hi Allen,

For instance -
2 Main forms -
frmMembersTabs
frmMembershipForm

Present line of code on a subform control is
Forms![frmMembersTabs]![TickWantsMemberCard] = True

The [TickWantsMemberCard] control is on both main forms.
I want this to find the same control when the parent Main form is either
[frmMembersTabs] or
[frmMembershipForm]

I tried
(me.parent.form) ![TickWantsMemberCard] = True
Forms!(me.parent.form) ![TickWantsMemberCard] = True

??

Tnx

DavidG (in Brisbane)
 
If it's in code, it will be something like this:
Me.Parent![TickWantsMemberCard] = True

If this is in the Control Source of a text box, try exactly this:
=[Form].[Parent]![TickWantsMemberCard]
Form refers to the current form, which has a Parent property, which has the
control named TickWantsMemberCard.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DavidG said:
Hi Allen,

For instance -
2 Main forms -
frmMembersTabs
frmMembershipForm

Present line of code on a subform control is
Forms![frmMembersTabs]![TickWantsMemberCard] = True

The [TickWantsMemberCard] control is on both main forms.
I want this to find the same control when the parent Main form is either
[frmMembersTabs] or
[frmMembershipForm]

I tried
(me.parent.form) ![TickWantsMemberCard] = True
Forms!(me.parent.form) ![TickWantsMemberCard] = True

??

Tnx

DavidG (in Brisbane)
What problem are you striking with Me.Parent.Name? Access loads the
subform first, so that reference might not be available if you checked
really early (during load) or really late (during closing), but other
than that it should work fine.
 
Allen,
A big THANK YOU !!
Your help is greatly appreciated.

If it's in code, it will be something like this:
Me.Parent![TickWantsMemberCard] = True

If this is in the Control Source of a text box, try exactly this:
=[Form].[Parent]![TickWantsMemberCard]
Form refers to the current form, which has a Parent property, which has
the control named TickWantsMemberCard.
For instance -
2 Main forms -
frmMembersTabs
frmMembershipForm

Present line of code on a subform control is
Forms![frmMembersTabs]![TickWantsMemberCard] = True

The [TickWantsMemberCard] control is on both main forms.
I want this to find the same control when the parent Main form is either
[frmMembersTabs] or
[frmMembershipForm]

I tried
(me.parent.form) ![TickWantsMemberCard] = True
Forms!(me.parent.form) ![TickWantsMemberCard] = True

??

Tnx

DavidG (in Brisbane)
What problem are you striking with Me.Parent.Name? Access loads the
subform first, so that reference might not be available if you checked
really early (during load) or really late (during closing), but other
than that it should work fine.


What is the best way to refer to the MAIN form from a subform control ?
I can't seem to get Me.Parent.Name to work as I want.
 
Back
Top