Consulting

Results 1 to 2 of 2

Thread: Solved: Tabbed Pages Problem

  1. #1
    VBAX Regular jauner's Avatar
    Joined
    Nov 2005
    Posts
    60
    Location

    Solved: Tabbed Pages Problem

    I have a form that has tab pages with subforms on it. Is there a way I can know which tab has been clicked or which subform is currently active? I need to conditionally set some subform fields based on which one is up.


  2. #2
    When a different page is selected, the Change event is fired for the Tab Control object and the index for the newly selected page is stored in the tab's Value property. Value can then be used as the index for the Pages collection. So assuming your tab control is named tabCtl1 and it contains three pages named pag1, pag2, and pag3, (note: those are control names, not captions) you could use code like this in your form's module:
    [VBA]
    Option Explicit

    Private Sub tabCtl1_Change()
    Select Case tabCtl1.Pages(tabCtl1.Value).Name
    Case "pag1"
    ' Insert Page 1 code here
    Case "pag2"
    ' Insert Page 2 code here
    Case "pag3"
    ' Insert Page 3 code here
    Case Else
    ' Enter default code here
    End Select
    End Sub
    [/VBA]

Posting Permissions

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