none
Tab Order with Tab Controls RRS feed

  • Question

  • I have form called frmFallsInputPast that has two combo boxes and a text box. The first combo box is called cboAcctNum.  It also has a Tab Control that has multiple combo boxes, text boxes and check boxes.  I want to set the tab order so that it starts with cboAcctNum and then jumps to the combo boxes, text boxes and check boxes on the first tab of the Tab Control.  I actually want it to skip the other combo box and text box on frmFallsInputPast that are not on the Tab Controls as well.  How would I do this?  Thanks Chuck 
    Chuck W
    Friday, July 29, 2011 7:52 PM

Answers

  • You can set the tab order on each tab control.   Just select the control and then go to the VIEW > TAB ORDER and you can then set the tab order.  If you don't want a control, or controls, included then set the TAB STOP property of those controls to NO. 

    In order to jump from a control to the tab control I do this - I put a tiny text box (height and width of .001") on the form and then include it in the tab order for the form and then put in some code in the Got Focus event to send it where I want.  Then I would do the same on each tab so have it tab through in order.

    I hope that makes sense.  I would post a sample but there is no way to do it here and I don't have access to my website's FTP for uploading while at work.


    Bob Larson, Access MVP 2008-2010, 2011
    • Marked as answer by ChuWil Wednesday, August 3, 2011 3:13 PM
    Friday, July 29, 2011 9:27 PM
  • To select the first page of a tab control, set the tab control's Value to the page number as in the page's properties.  Then procedure could then look like:

    Private Sub txtGoToTab_GotFocus()
      Me.TabCtl1 = 0   'not sure you need this
      Me.cboRoomNumber.SetFocus
    End Sub
    
    

    • Marked as answer by ChuWil Thursday, August 4, 2011 2:09 PM
    Thursday, August 4, 2011 12:25 AM
  • To select the first page of a tab control, set the tab control's Value to the page number as in the page's properties.  Then procedure could then look like:

     

    Private Sub txtGoToTab_GotFocus()
    
     Me.TabCtl1 = 0  'not sure you need this
    
     Me.cboRoomNumber.SetFocus
    
    End Sub
    
    
    
    

     


    To get the tab you don't need to set the value to the first page first, you can go directly there.  But it seems that you have to select the tab first before setting focus on a specific control or subform.  But also, I would suggest using the page name instead of the value for the tab control as the pages could possibly change order at some point but if you use the code below you can ensure that the actual page you want is displayed.

    Either:

    Me.PageNameHere.SetFocus

    or:

    Me.TabControlNameHere.Pages("PageNameHere").SetFocus

    or:

    Me.TabControlNameHere = Me.TabControlNameHere.Pages("PageNameHere").PageIndex

    Personally, I like the last one myself as it seems to be more consistent.


    Bob Larson, Access MVP 2008-2010, 2011
    • Marked as answer by ChuWil Thursday, August 4, 2011 2:18 PM
    Thursday, August 4, 2011 1:39 PM

All replies

  • You can set the tab order on each tab control.   Just select the control and then go to the VIEW > TAB ORDER and you can then set the tab order.  If you don't want a control, or controls, included then set the TAB STOP property of those controls to NO. 

    In order to jump from a control to the tab control I do this - I put a tiny text box (height and width of .001") on the form and then include it in the tab order for the form and then put in some code in the Got Focus event to send it where I want.  Then I would do the same on each tab so have it tab through in order.

    I hope that makes sense.  I would post a sample but there is no way to do it here and I don't have access to my website's FTP for uploading while at work.


    Bob Larson, Access MVP 2008-2010, 2011
    • Marked as answer by ChuWil Wednesday, August 3, 2011 3:13 PM
    Friday, July 29, 2011 9:27 PM
  • Bob, Thanks for your help. I am a novice vba user. I created a text box like you suggested and called it txtGoToTab on my main form (I will resize it later) and went to the properites and select On Got Focus and selected Code Builder. This created the code listed below. The name of the Tab Control that I want this text box to jump to is called TabCtl1 and the first field I want to go to is called cboRoomNumber. I have already set the tab order on the first page of this Tabl Control with cboRoomNumber being the first item. Any idea what code I would write to jump to page one of this control? Private Sub txtGoToTab_GotFocus() End Sub
    Chuck W
    Tuesday, August 2, 2011 1:34 PM
  • Hi Bob,

     

    Thank you very much for your friendly assistance!

     

    I would post a sample but there is no way to do it here and I don't have access to my website's FTP for uploading while at work.

     

    Well, you can upload your sample to https://skydrive.live.com/ and share the link with us.

     

    PS: Your article of Easy way to remember how to refer to subforms is really great!

     

    Best Regards,


    Macy Dong [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 3, 2011 5:06 AM
  • Well, you can upload your sample to https://skydrive.live.com/ and share the link with us.

     

    I would be able to if they didn't block that at my work as well (which they do).
    Bob Larson, Access MVP 2008-2010, 2011
    Wednesday, August 3, 2011 8:12 PM
  • They block that link at my work too but I figured it out.  The entire tab control appears as an object in the tab order of the main form so I select the tab control after the combo box that I want to start with.  The user needs to press tab twice but it does jump from my combo box on my main form to the first combo box on the tab control.  Thanks,  Chuck 
    Chuck W
    Wednesday, August 3, 2011 8:24 PM
  • To select the first page of a tab control, set the tab control's Value to the page number as in the page's properties.  Then procedure could then look like:

    Private Sub txtGoToTab_GotFocus()
      Me.TabCtl1 = 0   'not sure you need this
      Me.cboRoomNumber.SetFocus
    End Sub
    
    

    • Marked as answer by ChuWil Thursday, August 4, 2011 2:09 PM
    Thursday, August 4, 2011 12:25 AM
  • To select the first page of a tab control, set the tab control's Value to the page number as in the page's properties.  Then procedure could then look like:

     

    Private Sub txtGoToTab_GotFocus()
    
     Me.TabCtl1 = 0  'not sure you need this
    
     Me.cboRoomNumber.SetFocus
    
    End Sub
    
    
    
    

     


    To get the tab you don't need to set the value to the first page first, you can go directly there.  But it seems that you have to select the tab first before setting focus on a specific control or subform.  But also, I would suggest using the page name instead of the value for the tab control as the pages could possibly change order at some point but if you use the code below you can ensure that the actual page you want is displayed.

    Either:

    Me.PageNameHere.SetFocus

    or:

    Me.TabControlNameHere.Pages("PageNameHere").SetFocus

    or:

    Me.TabControlNameHere = Me.TabControlNameHere.Pages("PageNameHere").PageIndex

    Personally, I like the last one myself as it seems to be more consistent.


    Bob Larson, Access MVP 2008-2010, 2011
    • Marked as answer by ChuWil Thursday, August 4, 2011 2:18 PM
    Thursday, August 4, 2011 1:39 PM