Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing subform focus.

Status
Not open for further replies.

Hayton

Technical User
Oct 17, 2001
257
NZ
Hello Everyone,

I have a form called frmMembers which contains a subform (fsubAddress). When I tab out of the last field in frmMembers I need the focus to go to the first field in the subform (ResidentialAddress). Currently it will go to the last field that had focus for the previous record.

I tried this code but to no avail:
Me!fsub2Address.SetFocus
Me!fsub2Address!ResidentialAddress.SetFocus

Any suggestions appreciated.

Hayton McGregor

 
Assuming that you always fill in the last field in your main form...maybe it would work to put code on the last field in your main form's AfterUpdate event to SetFocus to the first field in the Subform.

Tom



 
Tom the code is set up as you have suggested.

Hayton McGregor

 
Try setting the tab order in the subform. If I'm not mistaking, by default it sets the focus to the first field in the tab order. Set ResidentialAddress as the first field in the tab order.

Good Luck,

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Hi TwoOdd, the tab order was set up as you suggested. Still the same result.

Hayton McGregor

 
Hello,

use a commandbutton (transparency = true) after your last field in the main form. Your code should be placed in the GotFocus event of that new commandbutton.

So you can be sure thant the coude runs if you made no changes in the last field.

Regards
Daniel S.
 
Try using the subforms On Got Focus to set the focus for ResidentialAddress. That's about all I can think of this late at night.

Good Luck,

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Hayton
I just checked the Microsoft Knowledge Base. There is an article 209689 that talks about how to go to a subform control from a main form.

Hope that helps.
Tom
 
Daniel,
Thanks for tip, it works for mu application.

Hayton McGregor

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top