• Click on a tab in a tabcontrol (2000)

    Author
    Topic
    #401970

    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

    Viewing 1 reply thread
    Author
    Replies
    • #796542

      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

      • #796548

        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

        • #796616

          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

          • #796648

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

          • #796649

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

        • #796617

          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

      • #796549

        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

    • #796543

      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

    Viewing 1 reply thread
    Reply To: Click on a tab in a tabcontrol (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: