Tabbed Control in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wayneyh
    New Member
    • Mar 2008
    • 67

    #1

    Tabbed Control in form

    Hi All

    My next issue is that i have a form that has a tabbed control on it with 6 pages. I would like to code the tabbed control so that when the user has entered data into the last field on page1, then presses the tab button on the keyboard it moves to the first field on page2 and so on. Can this be done and if so could you show me the code to do this.

    kindest regards

    Wayne
  • RuralGuy
    Recognized Expert Contributor
    • Oct 2006
    • 375

    #2
    Add an invisible control to each tab that is at the end of the Tab sequence for that page. In the OnEnter or GotFocus event of that control move the focus to the control you want on the tab page you want.

    Comment

    • DonRayner
      Recognized Expert Contributor
      • Sep 2008
      • 489

      #3
      Maybe something like this for the KeyDown event on your last control.

      TextControlName = Name of the last control on the page
      TabControlName = Name of your Tab control
      PageName = Name of the Tab page you want to go to
      NextTextControl = Name of the first text control on the new tab

      Code:
      Private Sub TextControlName_KeyDown(keycode As Integer, shift As Integer)
      If keycode = vbKeyTab Then
         Me.TabControlName.Pages.Item("PageName").SetFocus
         Me.NextTextControl.SetFocus
         Exit Sub
      End If
      End Sub

      Comment

      • RuralGuy
        Recognized Expert Contributor
        • Oct 2006
        • 375

        #4
        I'm pretty sure that setting the focus to a control on the 3rd page of the tab control will also switch the tab control to Page 3. I misspoke in my first post. The control can *not* be invisible. Just make it transparent and 1 pixel by one pixel.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          This Link may help you also:

          Comment

          • Wayneyh
            New Member
            • Mar 2008
            • 67

            #6
            Thank you all for your replies. I have tried all the different codes and they all seem to work one way or another.

            Thanks again

            Wayne

            Comment

            Working...