Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Click on a tab in a tabcontrol (2000)

    The "On Click" event for an individual tab in a tabcontrol only works if I click INSIDE the tab page (not the header).
    The "On Click" event for the entire tabcontrol works if I click on ANY of the tab headers.

    How do I run a macro when a specific tab header is clicked?

    John

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Click on a tab in a tabcontrol (2000)

    Use Tab Control Change event. Example:

    Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
    Case 0 ' 1st page
    ' do something
    Case 1 ' 2nd page
    ' do something else
    Case 2 ' 3rd page
    ' do nothing
    End Select
    End Sub

    Note that the page indexes are zero-based, so first tab value is zero (0), etc.

    HTH

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Click on a tab in a tabcontrol (2000)

    Excellent.
    I couldn't think of any use for the on-click event in the page tab headers, so I'd presumed it had to be the tabcontrol event.
    Why "on-change" rather than "on-click"? Just curious about this
    john

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Click on a tab in a tabcontrol (2000)

    Don't know reason, except it's not too intuitive when first using tab controls. If you look at Access Help, it says: "The Change event occurs when the contents of a text box or the text portion of a combo box changes. It also occurs when you move from one page to another page in a tab control." And: "The Click event occurs when the user presses and then releases a mouse button over an object." Not too useful.... The best way to find out which event does what for a given type of control is to create dummy event procedures like this:

    Private Sub Textbox1_Click()
    MsgBox "Textbox1 Click Event", vbInformation, "ON CLICK EVENT"
    End Sub

    Then test to see exactly when various events are triggered as evidenced by the msgbox displayed. This is also useful when trying to determine the exact sequence of events, which is not always intuitive either.

    HTH

  5. #5
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Click on a tab in a tabcontrol (2000)

    Thanks Mark
    Sometimes I guess it's best not to ask why - just accept that it just does!

Posting Permissions

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