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

Req: How to SetFocus or SelectObject on SubForm from outside form

54 views
Skip to first unread message

RgA

unread,
Apr 13, 1999, 3:00:00 AM4/13/99
to

I have a "MainForm" with three tab controls
The second tab "PageTwo" has a "SubForm".

From another forms code "SearchForm" I set the
.RecordSource for MainForm

Okay, Now I want to GoToControl [FirstControl] on the SubForm on PageTwo

I have tried all things in the known universe to get to a control on this
page two sub form. I can easily GoToControl [anyone] on the MainForm ..

But, when I try to get to a control on the SubForm ..
Message "doesn't exist"

I know how to reference controls on sub forms.
Forms![MainForm]!SubForm.Form!FirstControl

Even thinking that GoToControl only works with "active" form.
So ... I've even tried to
.SetFocus or even
DoCmd.SelectObject

But No Go ..
Can't even seem to make the SubForm Active.

Assistance MUCHO appreciated.


RgA

unread,
Apr 13, 1999, 3:00:00 AM4/13/99
to
Here's the answer:

Tip: Walk away and come back.

Forms![MainForm]!SubForm.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "FirstControl"

Just using up a little USENET space to think ..

RgA wrote in message <#KjoDTeh#GA....@cppssbbsa02.microsoft.com>...
>

gHaD

unread,
Apr 13, 1999, 3:00:00 AM4/13/99
to
Try:
------

Forms![MainForm]!SubForm!FirstControl.SetFocus


--
+++++++++++++++++++++++++++++++++++++++
+++ gHaD (Aaron Robinson) +++
++ MJM-PC Solutions, Inc. ++
++ Chicago, IL ++
++ ++
++ -> ICQ# 5686832 <- ++
++ Before they invented drawing ++
++ boards, what did they go back to? ++
+++++++++++++++++++++++++++++++++++++++

Trey Williams

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to RgA
RgA,
I think I understand your problem. I have had these problems myself. I
have a form with a few subforms where I want the user to be able to tab
through all the fields smoothly. I use the KeyDown event in VBA to force the
focus to a particular control when the Tab key is pressed. The procedure
blocks out the default action of the tab key (Keycode = 0) and then runs a
macro with GoToControl actions (when I tried GoToConrol in VBA, it got those
errors you described). Anyway - I have two lines in the macro, one to go to
the subform control, the second to go to the first field in the subform.
This seems to work beautifully for me. I also have it tab from one subform
to another, instead of moving to the next record in the subform. In short,
if a user is in a subform and wants to move to the next field, they press
Tab, if they want to add another record in the subform, they press Enter
instead.
Hope this helps you.
- TMW

Trey Williams

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to RgA

Trey Williams

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to RgA

Trey Williams

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to RgA

Trey Williams

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to

Mike Reck

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to
What you have to do first is make the second tab page active. Then you can
set the control to be active. The reason that you can't set it to be the
active control first is because it must be visible on.

Hope this helps
Mike Reck
Ameritech Data Networking Solutions


Trey Williams wrote in message <371F299F...@jhmi.edu>...

0 new messages