Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2002

    Unanswered: Why doesn't the OnClick Property of Tabs Work ?

    I have many forms with tabs and have never been able to make the On Click property of a tab trigger when I click on the tab.

    The code is pretty simple:

    Private Sub tabPastCalls_Click()
    Call Charge_AfterUpdate
    End Sub

    I have tried variations, and I have not been able to make this code run when I click on the tab.

    I can work around it by using the On Change event for the main tab, but it is slower.
    Also the On Click event for the main tab works if you click in a blank space along the main tab header ????

    Anyone know what I am doing wrong ?? Please offer any suggestions.

    Thanks !

  2. #2
    Join Date
    Nov 2004
    Bangor, ME USA
    Are you trying to trigger this on each tab, or just certain ones. and you say that you work around it by using onchange instead. again, on each tab or just one.

    for every tab to trigger the code try clicking on the tabcontrol itself and not the tab.

    I am no expert and don't claim to be, but I have tabcontrols on many of my forms and have code triggered on the onchange event of the control itself and have had no problems.

    maybe someone else can guide you further but HTH

    Kevin M Carman

  3. #3
    Join Date
    Feb 2002
    Yes, I am trying to trigger on certain tabs, because I want to trigger different events when I click on certain tabs.
    The onchange event I am using just uses the Case 0, Case 1 etc... to see which tab I pressed and is working OK, but would just like to be able to put code under each individual tab to keep it straighter in my head.

    I appreciate your help
    I may end up just staying with the onchange event but just can't figure why each tab wont trigger an event specific to that tab, it may not supposed to, but I would think it would. ??

    Thank You

  4. #4
    Join Date
    Nov 2003
    Both the Tab Control and each Page within in it do in fact have individual OnClick events which serve the purpose they were initially designed for.

    Each Page within the Tab Control's Page Collection contains the OnClick event but the event is global to the entire page only, as is the same with typical Forms. You have to consider each Page as a individual Form which you place Controls onto.

    The Tab Control's OnClick event is global to the entire to must be considered as a Form since controls can be placed onto it that are global to all Pages, not just individual Pages.

    In essence, when you place a Tab Control on a Form, what you are getting are a bunch of Forms in a Form on a Form (so to speak)

    The OnChange event is in place to serve exactly for what it is named. To fire when a Tab selection (or Focus) is Changed.

    The issue of using the OnClick event for each Page when the Page is in fact selected is a minor one and you can work around this by simply Calling the event from the Tab Control's OnChange event. For example:
    Private Sub TabCtl0_Change()
       Select Case Me.TabCtl0.Value + 1
         Case 1
            Call Page1_Click
         Case 2
            Call Page2_Click
       End Select
    End Sub
    If you actually use the Tab Control later on to any real extent, you may find that firing the Page OnClick event when a Page selection is made, may in fact provide an undesirable effect.

    I would recommend you play your cards with the Tab Control's OnChange event and structure your code so that it wont be so confusing to you.

    Self Taught In ALL Environments.....And It Shows!

  5. #5
    Join Date
    Feb 2002
    Thank You !

    That makes sense. I had to read it a couple of times for it to sink in, but that makes sense.
    And I am already using the onchange event, and thanks to you as a matter of fact, because I read one of your posts last year on the subject and found it very useful. I have read many of your posts and have learned a lot from them, Thank You for helping...

Posting Permissions

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