Field Name syntax, nested subforms

A

aemAndy

Pretty straightforward question here -

How do I correctly refer to a field on a subform of a subform?

So, I have forms set up to related tables -

"frmMainForm"
- Field1
- Field2
- ParentField3

"sfrmSubForm" (subform inside "frmMainForm")
- ChildField1 (Linked to the main form's "ParentField3")
- subField2
- subParentField3

"sfrmSubSqaredForm" (subform inside "sfrmSubForm', nested inside frmMainForm)
-ChildChildField1 (Linked to the first generation's "subParentField3")
-subsubField2

Let's suppose I'm in another form, my main form and the two nested subforms
are open and I want to refer to a field on the grandchild form (this means
all "Me.xxx" names are out).

How do I refer to "subsubField2"
 
S

strive4peace

Hi Andy,

me.sfrmSubForm.form.sfrmSubSqaredForm.form.subsubField2

the reason you need .form after the subform reference is
because the first reference is the subform control itself --
its SourceObject, LinkMasterFields, LinkChildFields,
Height, Width, etc -- by using .Form, you are specifying
that you want to go INTO the form in the subform control

make sure you are using the NAME property for subsubField2,
not its controlsource -- always use control names in code


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
A

aemAndy

Okay.... that's where I missed it before - I used the ".form" before the
field, but not between the two sub-forms.

Good "heads up" on using the form control names, I learned that the hard way
a while ago.

Thanks very much for the help.
 
S

strive4peace

you're welcome, Andy :) happy to help

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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