Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    13

    Unanswered: How to run code on clicking Tab

    Can anyone help please?
    I'm using Tab pages with subforms which in turn, contain command buttons.
    As a default, I want to execute the code of a particular button as soon as the user clicks on the Tab page i.e. the user will not have to click the button the first time he accesses the Tab page.

    I tried setting the button as a default but this did not run the code "automatically" as I wished it to.
    I also tried creating an event procedure on the Event "On Click" property field of the Tab page and copied the button's code. This had no effect.
    Any ideas?

  2. #2
    Join Date
    Dec 2002
    Posts
    97

    Tab Conrol Code execute

    If I understand you correctly you want your user to click a tab in the tab control and have that execute a piece of code.

    That being said...it's pretty easy.

    Private Sub Page2_Click()

    ....Your Code Here....


    End Sub

    Where Page2 is the name of the respective tab.

    Hope this helps.

    Chris

  3. #3
    Join Date
    Feb 2005
    Posts
    19
    I've also tried using the 'click' event and had no joy either. What does work is the following:

    Using the whole tab control 'Change' event - that not the individual tab but the whole control. Thus:
    Private Sub TabControl_Change()
    Dim tbc As Control
    Dim pge As Page
    Dim ctl As Control

    ' Return reference to tab control.
    Set tbc = Me!ContactsTab
    ' Return reference to currently selected page.
    Set pge = tbc.Pages(tbc.Value)

    If pge.Name = "MyTabPage1" Then
    code
    ElseIf pge.Name = "MyTabPage2" Then
    code
    etc

Posting Permissions

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