Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Kitchener, Ontario, Canada
    Posts
    228
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Tabs (2002 (10.2616.2625))

    I have a form with 10 tabs. The form always opens to the first tab. How do I get the form to open to a different tab?

  2. #2
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Tabs (2002 (10.2616.2625))

    You will need to have the form open with some form of the following:

    Private Sub Form_Open(Cancel As Integer)
    Me.TabCtl0.Pages.Item(indx).SetFocus
    End Sub

    The index is relative to zero so to display the tenth tab the index will need to be 9.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Kitchener, Ontario, Canada
    Posts
    228
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Tabs (2002 (10.2616.2625))

    I can't place it there as I want the form to open to the first tab normally. I only want it to open to a specific tab if a button is pressed. The button is found on tab 12 and what it does is :

    close the form
    Run a del query
    Run an append query
    Open the form back to tab 12

    Here is the code I have written so far for the button.

    Private Sub Operation_List_Click()
    On Error GoTo Err_Operation_List_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    Call MsgBox("This function is to rebuild the Operation List. Please answer Yes to all questions.", vbInformation, "Operation List")

    DoCmd.Close ' main form closes

    stDocName = "Operation List Unload" ' this is a del query used to clean out the Operation List
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    stDocName = "Operation List Load" 'this is an append query used to refill the Operation List
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    stDocName = "Master Information List"
    DoCmd.OpenForm stDocName, , , stLinkCriteria ' re open the main form
    ' This is the point where the form should switch to tab 12

    Exit_Operation_List_Click:
    Exit Sub

    Err_Operation_List_Click:
    MsgBox Err.Description
    Resume Exit_Operation_List_Click

    End Sub

    I have tried adding the line

    Me.TabCtl3.Pages.Item(12).SetFocus

    at the proper location ( I think ) in the code. but it tells me that the expression I entered refers to an object that is closed or does not exist

    Also I would love to get rid of the MsgBox but I don't know how to make a del query or append query run without them asking the conformation questions.
    Attached Images Attached Images

  4. #4
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Tabs (2002 (10.2616.2625))

    Corey,

    I would set a global value from here to the value for this tab. Add the On Open Event to get the value. (The global should be set to zero the first time it is used.)

    dim tabVal as long
    tabval = getTabVal
    Me.TabCtl3.Pages.Item(tabVal).SetFocus


    Be sure to set the global back to zero when you want the first tab.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form Tabs (2002 (10.2616.2625))

    In addition to Don's reply: why do you want to close and reopen the form? Issuing Me.Requery is probably enough if the underlying data have changed.

    If you execute action queries, you can insert a line

    <code>DoCmd.SetWarnings False</code>

    before, and

    <code>DoCmd.SetWarnings True</code>

    after the DoCmd.OpenQuery lines. Preferably, put the last instruction between <code>Exit_Operation_List_Click:</code> and <code>Exit Sub</code>, so that it will always be executed, even if an error occurs.

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Form Tabs (2002 (10.2616.2625))

    Even simpler is:

    Me.TabCtl0 = index
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •