Results 1 to 5 of 5
  1. #1
    shoelesscraig is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    53

    Open Form To Specific Tab

    I have a report that has a button on each row, where if you click the button it will open a report (called "Project Proposal Summary") and go to the corresponding record ID based upon which button you clicked. The code is the following:



    Private Sub GoToRecButton_Click()


    DoCmd.OpenForm "Project Proposal Summary", , , "ID = " & Me.ID


    End Sub



    Works great, but I'd like to add one thing if possible and I don't know how to do it. The form that it opens has multiple tabs on it. Currently it just opens the form and shows the default 1st tab, but I'd really love it if it opened the form and went to my second tab, which is called "ActionItemsPage". This tab has a page index of 1. I'm thinking there is some code I could add that would make it open to that tab, but I have no idea what it would be. Keep in mind, I only want it to automatically go to this tab when I click the buttons on that particular report. If I just open that form normally, I want it to just open the default tab as it does now. Anybody have an idea?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    in the ON LOAD form event,
    TabCtl.Value = 2 (or the needed tab#)

    and FYI, you dont need a button on every row, a single button in the form header will do the same thing, with the same code.
    it uses the record the cursor is on, and is not as busy with hundreds of buttons.

  3. #3
    shoelesscraig is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    53
    Quote Originally Posted by ranman256 View Post
    in the ON LOAD form event,
    TabCtl.Value = 2 (or the needed tab#)

    and FYI, you dont need a button on every row, a single button in the form header will do the same thing, with the same code.
    it uses the record the cursor is on, and is not as busy with hundreds of buttons.
    I'm willing to try this, no problem. But won't this make that tab open every time, regardless of where it's opened from? I only want that to happen when opened with said button on the report.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Will not work if report is in Preview, only Report view. Put code in the button Click event. Options:

    1. pass a value to the form using OpenArgs

    DoCmd.OpenForm "formname", , , , , , "2"

    and code in the form OnLoad event uses as criteria in a conditional statement

    If Me.OpenArgs = "2" Then TabCtl.Value = 2

    2. use full form name reference
    Forms!formname.TabCtl.Value = 2
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    shoelesscraig is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    53
    Quote Originally Posted by June7 View Post
    Will not work if report is in Preview, only Report view. Put code in the button Click event. Options:

    1. pass a value to the form using OpenArgs

    DoCmd.OpenForm "formname", , , , , , "2"

    and code in the form OnLoad event uses as criteria in a conditional statement

    If Me.OpenArgs = "2" Then TabCtl.Value = 2

    2. use full form name reference
    Forms!formname.TabCtl.Value = 2
    Fantastic! Worked like a charm! Thanks so much...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open form with specific record
    By Lukael in forum Programming
    Replies: 14
    Last Post: 11-16-2015, 06:31 AM
  2. open form At specific time
    By azhar2006 in forum Forms
    Replies: 1
    Last Post: 07-29-2014, 04:10 PM
  3. open specific form after login
    By manojsikar1 in forum Forms
    Replies: 1
    Last Post: 11-21-2012, 08:54 AM
  4. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 AM
  5. Open to specific form
    By ecpike in forum Forms
    Replies: 2
    Last Post: 06-12-2009, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums