Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Oct 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ref tab names in a Tab control (access 2002 sp1)

    I have a form with a tab control in it with three tabs (i.e. products, reports, and customers)
    I have a text box (txtTabItem) at the bottom of the tab control that I would like to create an expression in something like: if(tab = products, text1),(tab=reports, text2),(tab=customers, text3). So that the text changes depending upon which tab is selected. I'm not sure how to reference the "tab". Any thoughts would be appreciated.
    thank you!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Ref tab names in a Tab control (access 2002 sp1)

    The tab control has a Value property. This is the zero-based index of the active tab page: if the first tab page is active, Value = 0, if the second tab page is active, Value = 1 etc.

    So you can use code (tabCtl is the name of the tab control) in the OnClick event of the tab control:

    Select Case tabCtl.Value
    Case 0
    txtTabItem = "Something"
    Case 1
    txtTabItem = "Else"
    ...
    End Select

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Ref tab names in a Tab control (access 2002 sp1)

    Try using a Switch function. The tabs have an index number, so it's simplest to just test the value of the tab control to determine which page is active.

    Switch(tab = 0, text1, tab = 1, text2, tab = 2, text3)
    Charlotte

  4. #4
    Star Lounger
    Join Date
    Oct 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Ref tab names in a Tab control (access 2002 sp1)

    thanks for your help. What I have looks like this:
    Private Sub TabCtl0_Click()
    Select Case tabCtl.Value
    Case 0
    txtTabItem = "Product Categories"
    Case 1
    txtTabItem = "Products for Sale In Inventory"
    Case 3
    txtTabItem = "Distributors"
    Case 4
    txtTabItem = "Management Reports"
    End Select
    End Sub
    ***
    My text box (txtTabItem) isn't updating with the case items. Can you tell what i'm doing wrong? Thanks.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Ref tab names in a Tab control (access 2002 sp1)

    Sorry, my error. You need to use the OnChange event instead of the OnClick event. I didn't really check when I wrote my earlier reply.

    Note: if your tab control is named TabCtl0, you should refer to that name in the code too:
    Select Case TabCtl0.Value
    But that is probably only a typo in your post.

    Regards,
    Hans

  6. #6
    Star Lounger
    Join Date
    Oct 2001
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Ref tab names in a Tab control (access 2002 sp1)

    Working perfectly now. thanks again for your help!

Posting Permissions

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