Need help changing focus between open forms

D

dee

I have an unbound form called AllM
It contains a tab control, each of which contains an independent open form.
Tab1 form = FmMailed
Tab2 form = FmVerify
Tab3 form = FmpOnly

I'm trying to switch focus from one form to another on certain events, but can't get anything to work.

I have tried to switch from the Tab1 form "FmMailed" to the Tab2 form "FmVerify" using various code:

Forms![FmVery].LastName.SetFocus
Forms![AllM]![FmVery].LastName.SetFocus

and many other variation. All give errors.

I'd be forever grateful if someone could correct my code.
 
J

John W. Vinson

I have an unbound form called AllM
It contains a tab control, each of which contains an independent open form.
Tab1 form = FmMailed
Tab2 form = FmVerify
Tab3 form = FmpOnly

I'm trying to switch focus from one form to another on certain events, but can't get anything to work.

I have tried to switch from the Tab1 form "FmMailed" to the Tab2 form "FmVerify" using various code:

Forms![FmVery].LastName.SetFocus
Forms![AllM]![FmVery].LastName.SetFocus

and many other variation. All give errors.

I'd be forever grateful if someone could correct my code.

Sorry, a tab control cannot "contain an independent open form". It may contain
a Subform Control which itself contains a form object, but an "independent
open form" is really independent, and cannot be "in" the tab control.

Guessing that you in fact have Subform controls on the tab page, they won't be
in the Forms collection; instead they must be referenced via the Subform
Control which contains them. The name of this control will often be the same
as the name of the form it contains, but not always, so do check.

What you'll need to do is set focus to the subform, and THEN to the control on
the subform - a two-step operation:

Me!FmMailed.Form.SetFocus ' to set focus to the form within the FmMailed
' Subform control
Me!FmMailed.Form!LastName.SetFocus

--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.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