Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160

    Unanswered: tab buttons not working properly

    a big hello to everyone.

    Just a quick question someone may have the answer to...

    Im using tab pages to navigate across my form.

    I am trying to use the on click command to enter a value into a unbound text box depending on which tab the user presses. however the code only runs when I click on a blank area within the page...not the actual button?

    Any ideas?

    thanks
    Marcus

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Here's quick tutorial some have found helpful:

    The first thing to understand is that tabbed pages are indexed starting with zero, i.e. the first page has a value of 0, second page has a value of 1, third page has a value of 2, etc.

    Secondly, you need to understand that the OnClick event of a tabbed page only fires when you click on the page itself, not the tab at the top of the page!

    Lastly, you need to understand that the tabbed control change event fires anytime the tabbed pages change. But to base something on the change event, you have to identify the particular page that has focus.

    Code:
    Private Sub YourTabbedControl_Change()
      Select Case YourTabbedControl 
        Case 0  ‘First Page
          ‘Code for Page 1
        Case 1  ‘Second page
          ‘Code for Page 2
       Case 2   ‘Third page
         ‘Code for Page 3
      End Select
    End Sub
    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    ok thanks...Ive put the code in the Tabct18 on change but i think i need to set the focus somehow. I'm just searching the forum and the internet to see how I set focus.

    at the moment focus must be on page 0 as it runs that bit of code regardless of which tab button i press.
    thanks again
    marcus

  4. #4
    Join Date
    Sep 2006
    Posts
    265
    On the Parent is an Unbound control called Page_No

    On the TabControl On Change is this Function:

    Code:
    Function Page_No()
    
        With CodeContextObject
            .[Page_No] = .[TabCtl0]
        End With
    
    End Function
    Simon

  5. #5
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    Hi Simon,

    I tried putting the code in the on change command but it replies with Expected end sub. Not sure I'm putting it in correctly as i am new to VB.
    thanks
    marcus

  6. #6
    Join Date
    Sep 2006
    Posts
    265
    Sorry this Function is on [TabCtl0] On change

    This is a Function not a Sub. Why not a Sub because it works on any Tabulated Form.

    Simon

  7. #7
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    i must be doing something wrong. My tab control is TabCtl8 so i enter the code you sent me in the on change property but nothing happens? I'm changing the reference to match my TabCtl8 ... is that right?

  8. #8
    Join Date
    Sep 2006
    Posts
    265
    Well change to:
    Code:
    Function Page_No()
    
        With CodeContextObject
            .[Page_No] = .[TabCtl8]
        End With
    
    End Function
    Simon

  9. #9
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    i must be really stupid...You lost me on the parent bit?

    Not sure where to stick the code. can't find any info about Page_No function. Don't know how to use functions.....

  10. #10
    Join Date
    Sep 2006
    Posts
    265
    There is an unbound control of the Main Form called Page_No.

    Simon

Posting Permissions

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