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

Posted on 2006-04-27
Last Modified: 2008-03-17
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

Question by:Shaft960
    LVL 54

    Accepted Solution

    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

    LVL 16

    Expert Comment

    '<!-- 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 -->
    End Sub

    Author Comment

    Thank you it worked.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now