Identify nested form object

J

JimN

To ID a form's object - Forms!FormName!ObjectName.property,
a subform's object - Forms!FormName!SubformName.Form!
ObjectName .Property
So how do you Identify a nested Form?
Have tried - Form!FormName!SubformName.Form!
NestedFormName.Form!ObjectName.Property and several other
configureations but get error messages that a form cannot
be found or an object cannot be found.
Thanks Jim.......
 
S

Sandra Daigle

Hi Jim,

A subform is not open by itself - it is only open indirectly through the
subform control on the main form. So to reference a control on the subform,
you must also reference the subform control. If the subform control is named
sfrmSub1 and the control on the subform is named txtMyControl then from the
class module of the main form the correct reference to this control would
be:

'to assign a value

me.sfrmSub1.form.txtMyControl=123

Note that 'sfrmSub1' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmSub1.
 
M

Marshall Barton

JimN said:
To ID a form's object - Forms!FormName!ObjectName.property,
a subform's object - Forms!FormName!SubformName.Form!
ObjectName .Property
So how do you Identify a nested Form?
Have tried - Form!FormName!SubformName.Form!
NestedFormName.Form!ObjectName.Property and several other
configureations but get error messages that a form cannot
be found or an object cannot be found.


Check the name of the subform CONTROLS on their parent form.
The name you use in the above references must be the name of
the subform control, which may or may not be the same as the
name of the form it is currently displaying. In other
words, your reference needs to be:

Forms!FormName!SubformControlName.Form!ObjectName.Property
 
G

Guest

Hey Sandra,

My problem is not at the subform level, but to refernce a
control in a nested subform or sub-subform.

(e-mail address removed)
-----Original Message-----
Hi Jim,

A subform is not open by itself - it is only open indirectly through the
subform control on the main form. So to reference a control on the subform,
you must also reference the subform control. If the subform control is named
sfrmSub1 and the control on the subform is named txtMyControl then from the
class module of the main form the correct reference to this control would
be:

'to assign a value

me.sfrmSub1.form.txtMyControl=123

Note that 'sfrmSub1' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmSub1.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

To ID a form's object - Forms!FormName! ObjectName.property,
a subform's object - Forms!FormName!SubformName.Form!
ObjectName .Property
So how do you Identify a nested Form?
Have tried - Form!FormName!SubformName.Form!
NestedFormName.Form!ObjectName.Property and several other
configureations but get error messages that a form cannot
be found or an object cannot be found.
Thanks Jim.......

.
 
G

Guest

Hey Marsh,
Thanks for the reply. The real problem is a nested subform
or sub-subform. I can get to and from a subform, but there
is a nested form in the subform and I cannot get a value
into the nested (Sub-Sub)form from the form.
Jim...
 
S

Sandra Daigle

Hi Jim,

Then you just take it one more level - it's ugly but looks like this:

me.sfrmLev1Sub.form.sfrmLev2Sub.form.txtMyControl=123

This references the form property of the level 1 subform control, then
refernces the form property of the level 2 subform control ('sfrmLev2Sub').

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hey Sandra,

My problem is not at the subform level, but to refernce a
control in a nested subform or sub-subform.

(e-mail address removed)
-----Original Message-----
Hi Jim,

A subform is not open by itself - it is only open indirectly through the
subform control on the main form. So to reference a control on the
subform, you must also reference the subform control. If the subform
control is named sfrmSub1 and the control on the subform is named
txtMyControl then from the class module of the main form the correct
reference to this control would be:

'to assign a value

me.sfrmSub1.form.txtMyControl=123

Note that 'sfrmSub1' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object
that is referenced in the ControlSource of the subform control. To be
sure, open the main form and click once on the subform then check the
name property under the Other tab. Whatever you find there is what
belongs in place of sfrmSub1.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

To ID a form's object - Forms!FormName! ObjectName.property,
a subform's object - Forms!FormName!SubformName.Form!
ObjectName .Property
So how do you Identify a nested Form?
Have tried - Form!FormName!SubformName.Form!
NestedFormName.Form!ObjectName.Property and several other
configureations but get error messages that a form cannot
be found or an object cannot be found.
Thanks Jim.......

.
 
M

Marshall Barton

Hey Marsh,
Thanks for the reply. The real problem is a nested subform
or sub-subform. I can get to and from a subform, but there
is a nested form in the subform and I cannot get a value
into the nested (Sub-Sub)form from the form.
Jim...


Sorry, I just didn't see that scenario in your original
post. I see Sandra has explained it so you should be
squared away now.
 
S

Sandra

Hey Sandra.

Thanks for the repy, I will try it. Have a nice weekend,

Jim.....




-----Original Message-----
Hi Jim,

Then you just take it one more level - it's ugly but looks like this:

me.sfrmLev1Sub.form.sfrmLev2Sub.form.txtMyControl=123

This references the form property of the level 1 subform control, then
refernces the form property of the level 2 subform control ('sfrmLev2Sub').

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hey Sandra,

My problem is not at the subform level, but to refernce a
control in a nested subform or sub-subform.

(e-mail address removed)
-----Original Message-----
Hi Jim,

A subform is not open by itself - it is only open indirectly through the
subform control on the main form. So to reference a control on the
subform, you must also reference the subform control. If the subform
control is named sfrmSub1 and the control on the subform is named
txtMyControl then from the class module of the main form the correct
reference to this control would be:

'to assign a value

me.sfrmSub1.form.txtMyControl=123

Note that 'sfrmSub1' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object
that is referenced in the ControlSource of the subform control. To be
sure, open the main form and click once on the subform then check the
name property under the Other tab. Whatever you find there is what
belongs in place of sfrmSub1.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


JimN wrote:
To ID a form's object - Forms!FormName! ObjectName.property,
a subform's object - Forms!FormName!SubformName.Form!
ObjectName .Property
So how do you Identify a nested Form?
Have tried - Form!FormName!SubformName.Form!
NestedFormName.Form!ObjectName.Property and several other
configureations but get error messages that a form cannot
be found or an object cannot be found.
Thanks Jim.......

.

.
 

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