Access 2003 Macro Question:  How to set focus to a specific tab on a tab control within an existing macro?

Posted on 2007-10-12
Last Modified: 2012-05-05
I am trying to edit an existing Access database macro to include a new item.
I did not create it, and I am not sure how to add to it.
The macro itself appears not in raw code, but in a screen that lists all macros associated with the form.  Here is what is shown:

Macro Name                                  Action
CreateNewContact: On Click        GoToRecord

There is only this one action currently in this macro.
The details for the GoToRecord are as follows:
Object Type:  Form
Object Name:  Contacts
Record:  New

So, currently, when the macro runs, it will place you on a new record in the contact form.

This is what I want, but in addition to this, after placed on the new record, I want to place the user on a specific page on a tab control.

What do I need to add to place them on the page I want in the tab control?
Question by:sah18
    LVL 3

    Expert Comment

    Is this a button in the form that creates a new record?

    If so, then What I would do is Create a new Button using the Wizard to "Create new Record"
    Then go in and Edit the On Click Event and add to the Code

    me.TAB PAGE NAME.setfocus
    LVL 3

    Expert Comment

    BTW if the Wizard isn't working for you, the Wizard Generated Code is as follows:
     DoCmd.GoToRecord , , acNewRec
    LVL 9

    Author Comment

    it is a button that already exists on the form, that launches the macro.  I don't really want to re-create the button, as it is already fine the way it is.  I just want to add to the macro code.  Is there a way to have more than one line of code for the macro in that Macros screen that I described above?
    LVL 9

    Accepted Solution

    Ahhh, I solved this myself.  In case others need to do this:
    Just add an additional row beneath the previous action.
    Select "GoToControl", and then type in the TabPage name in the control text box.
    LVL 1

    Expert Comment

    Closed, 500 points refunded.
    EE Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

    759 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

    13 Experts available now in Live!

    Get 1:1 Help Now