• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Have Tab Control on Subform move to first Tab Control from outside the subform

I have a form called Main.  On this form I have a subform called Sub1.  On Sub1 I have 4 Tab pages.

On the main form I have a button that adds a new record.  What I want to do is when I push the add record button on the Main form, the sub1 form Tab page will move to the first page if it is not already on the first page.  Then I want the focus to go to a field on the main form.  This is the coding in the button:

   
DoCmd.GoToRecord , , acNewRec
Me.Invoice_TO.SetFocus


0
Shaft960
Asked:
Shaft960
1 Solution
 
nico5038Commented:
You can do that by first moving the focus to a control on the first tab followed by the SetFocus on the mainform.

DoCmd.GoToRecord , , acNewRec
Me.subformname.form.FieldOnFirstTab.SetFocus
Me.Invoice_TO.SetFocus

Nic;o)
0
 
GreymanMSCCommented:
'<!-- Substitute the names of your controls where needed -->

Private Sub TheAddNewButtonName_Click()
  '<!-- goto the new record / or use your own code -->
  DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
  '<!-- Set the Value of the Tab Control -->
  If Not Me.Sub1.Form!TheTabControlName.Value = 0 Then
    Me.Sub1.Form!TheTabControlName.Value = 0
  End If
  '<!-- Set the focus to the field you want -->
  Me.TheFieldName.SetFocus
End Sub
0
 
Shaft960Author Commented:
Thank you it worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now