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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto Control on subform

Status
Not open for further replies.

ohmbru2

Technical User
Jul 24, 2001
51
US
I'm trying to set the focus to a control on a subform, which is on a tab control. Do I need to reference the tab control?

The current focus is on another subform in the same tab control.

I have tried this, but get an error:

DoCmd.GoToControl "Forms![MainForm]![SubForm].Form![ControlName]"

This gets me to the subform, but it errors off when I add the control name:

DoCmd.GoToControl "[SubForm]"

I'm attaching this to the OnExit event of a field in a different subform.

 
This is really a forms question (forum702), but the steps involved I think would be

1 - set focus to the correct subform
2 - set focus to the correct control

Use the setfocus method

[tt]Forms![MainForm]![SubForm].SetFocus
Forms![MainForm]![SubForm].Form![ControlName].SetFocus[/tt]

Here's another sample thread702-886260.

If you're on one subform, and wish to set focus to another, you should also be able to use an abbreviated syntax like this, I think

[tt]Me.Parent![SubForm].SetFocus
Me.Parent![SubForm].Form![ControlName].SetFocus[/tt]



Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top