Results 1 to 8 of 8
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Tab Control Event

    This is a simple one I hope. I have a tab control (tabctl10) on a form with 7 pages. Depending on the page selected I want to display certain controls like txtFromDate and txtToDate. I have tried both the on Change event and the On Click event for the Page. The On Change event runs every time I click a different tab, which is what I want, but I want to write and If Then statement or a Case statement to run different code depending on the page selected. I can't seem to track down this property. This is what I am working with. It doesn't work, but you get the idea.


    Code:
    Private Sub TabCtl0_Change()
            
            If Me.TabCtl0.Control.Name = "Page57" Then
            MsgBox "hello"
                Me.txtFrom.Visible = True
                Me.txtTill.Visible = True
            Else
                Me.txtFrom.Visible = False
                Me.txtTill.Visible = False
            End If
            
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Google: Access tab control page has focus
    See if this helps http://www.fmsinc.com/MicrosoftAcces...abs/index.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thank you, thank you, thank you.

    Nice to hear from you again.

    Paul

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    if that doesn't work for you, here's one way to reference the page via it's caption.
    MsgBox Me.TabCtl28.Pages(Me.TabCtl28.Value).Caption
    Don't think I've ever used the control reference to a tab page - prefer to reference the pages collection
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I'm not finished, but it came out like this.

    Code:
        Select Case Me.TabCtl0.Value
            Case 0
                Me.txtFrom.Visible = False
                Me.txtTill.Visible = False
                
            Case 1
                Me.txtFrom.Visible = True
                Me.txtTill.Visible = True
            Case 2
                Me.txtFrom.Visible = True
                Me.txtTill.Visible = True
            Case 3
                MsgBox Me.TabCtl0.Pages(3).Name
            Case 4
                MsgBox Me.TabCtl0.Pages(4).Name
            Case 5
                MsgBox Me.TabCtl0.Pages(5).Name
            Case 6
                MsgBox Me.TabCtl0.Pages(6).Name
            Case Else
                MsgBox Me.TabCtl0.Value
        End Select

    Just what the doctor ordered.

    Paul

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    You might find this helpful:

    Wizard Form template


    It will show you how to work with the different pages of a tab control.

  7. #7
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks, Boyd.

  8. #8
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    You're welcome. Glad we could assist.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 03-24-2016, 03:11 PM
  2. Mousemove event determine control name
    By dcdimon in forum Programming
    Replies: 3
    Last Post: 07-01-2015, 04:26 PM
  3. Replies: 11
    Last Post: 11-13-2014, 08:52 PM
  4. tab control - firing a page on-click event
    By Chuck55 in forum Programming
    Replies: 7
    Last Post: 05-01-2012, 09:57 AM
  5. User focus control in AfterUpdate event
    By nosliwmada@gmailcom in forum Programming
    Replies: 3
    Last Post: 12-20-2010, 12:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums