Reference Syntax

  • Thread starter Thread starter Ross
  • Start date Start date
R

Ross

I have a Master form with a Tab Control (Page) on it.
Then, on top of one of tabs, I have another (different)
form. I want to reference a control on the form which is
embedded on the tab control.

What is the reference Scheme / Syntax to accomplish this
or where can I find it?

Form1----->Tab1-------->Form2------->Control1

Many Thanks

Ross
 
Hi Ross,

The "form which is embedded on the tab control" is actually a subform. 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.

To set focus to the subform control from the main form, you must first set
focus to the subform control itself:

me.sfrmSub1.setfocus
me.sfrmSub1.form.txtMyControl.setfocus

Note that the TabControl plays no part in the reference to the subform or
it's controls.
 
Sandra,

Thank You,

I will give it a try.

Ross
-----Original Message-----
Hi Ross,

The "form which is embedded on the tab control" is actually a subform. 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.

To set focus to the subform control from the main form, you must first set
focus to the subform control itself:

me.sfrmSub1.setfocus
me.sfrmSub1.form.txtMyControl.setfocus

Note that the TabControl plays no part in the reference to the subform or
it's controls.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a Master form with a Tab Control (Page) on it.
Then, on top of one of tabs, I have another (different)
form. I want to reference a control on the form which is
embedded on the tab control.

What is the reference Scheme / Syntax to accomplish this
or where can I find it?

Form1----->Tab1-------->Form2------->Control1

Many Thanks

Ross


.
 
On my website, see sig below, is a small sample database called
"SubformReference.mdb" which illustrates how to reference subforms and
sub-subforms.

BTW, the Tab control plays no part in the referencing scheme. Just ignore
it and act as if the subform is not on the tab. As far as the referencing
is concerned, it isn't.
 
Back
Top