Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Referencing subform on Tab Control

13 views
Skip to first unread message

SlowLearner

unread,
Sep 17, 2002, 10:11:33 AM9/17/02
to
Thanks in advance for any insight.

From the last control on frmMain I would like the focus
to tab next to the first field of the subform on a tab
control with two tabs. I can't seem to get the syntax for
referencing controls on a page on a subform on a tab.

Forms!frmMain!????How do you refer to the tab control &
pages????subfrmMysub.form![Mycontrol].SetFocus

Help! Please!

Sandra Daigle

unread,
Sep 17, 2002, 10:51:10 AM9/17/02
to
You don't have to reference the TabControl at all - so that makes things a
little easier.

To reference a control on a subform you make the reference via the form
object of the Subform control

Forms!frmMain.subfrmMySub.form.MyControl.SetFocus
me.subfrmMySub.form.MyControl.SetFocus

One of the keys to this is to understand that 'subfrmMySub' in the above
statement must be the name of the subform control on the main form. This may
or may not be the same name as the form object that is being used in the
ControlSource of the subform control. To be sure, click once on the subform,
then look at the name property of the control (under the Other tab).
Whatever you see there is what should be in the above reference.

Then when you reference the Form Property of the subform control, you get
access to the individual controls and properties of the form object itself.

If the code is in the class module of frmMain, you can (and should) use the
Me keyword instead of using the Forms!frmMain reference. This speeds things
up a tiny bit and it also makes it clear that what follows the Me keyword
belongs to the current form (and not another form floating around out
there).

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

Van T. Dinh

unread,
Sep 17, 2002, 10:54:17 AM9/17/02
to
The answer: don't refer to the TabControl or the Tab Page.

Forms!frmMain!SubformControl.Form! ....

should do.

--
HTH
Van T. Dinh
MVP (Access)

"SlowLearner" <kgai...@cox.net> wrote in message
news:0dc001c25e54$20ac45e0$39ef2ecf@TKMSFTNGXA08...

Joan Wild

unread,
Sep 17, 2002, 10:57:50 AM9/17/02
to
You don't. The subform is still a subform of the main form, whether it's on
a tab or not.

Joan Wild
Access MVP

"SlowLearner" <kgai...@cox.net> wrote in message
news:0dc001c25e54$20ac45e0$39ef2ecf@TKMSFTNGXA08...

0 new messages