ACC: How to Create a Cyclic Tab Order in a Form

Last reviewed: April 2, 1997
Article ID: Q112064
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes a technique that you can use to create a cyclic tab order on a form, so that pressing TAB in the last control on a form moves you back to the first control on the form (instead of moving you to the first control on the next record); and pressing SHIFT+TAB in the first control on a form moves you to the last control on the form.

NOTE: In Microsoft Access 7.0 and 97, the cyclic tab order of a form can be controlled by setting the form's Cycle property to All Records, Current Record, or Current Page. The information below applies to Microsoft Access versions 1.0, 1.1, and 2.0 only.

MORE INFORMATION

The following example demonstrates how to create a cyclic tab order on the Customers form in the sample database NWIND.MDB. This technique uses two transparent command buttons, one at the top and one at the bottom of the form's tab order. When you press TAB in the last control, or SHIFT+TAB in the first control, you run a macro attached to the OnEnter property of the transparent command button at the top or bottom of the form's tab order.

  1. Create a macro called CyclicCustomers with the following actions:

          MacroName   Action
          -----------------------
          GotoFirst   GotoControl
          GotoLast    GotoControl
    
          GotoFirst Actions
          ------------------------
          ControlName: Customer ID
    
          GotoLast Actions
          ----------------
          ControlName: Fax
    
    

  2. Open the Customers form in Design view and add the following two command buttons with no labels:

          Command Button
          ------------------------------------
          ControlName: btnGotoLast
    
             OnEnter: CyclicCustomers.GotoLast
             Transparent: Yes
    
          Command Button
          -------------------------------------
             ControlName: btnGotoFirst
             OnEnter: CyclicCustomers.GotoFirst
             Transparent: Yes
    
       NOTE: Make these buttons very small, and position them so that users of
       the form are unlikely to choose them accidentally.
    
    

  3. Set the form's OnOpen property to:

          OnOpen: CyclicCustomers.GotoFirst
    

    This is necessary because the btnGotoLast button will be the first control in the form's tab order. If you do not set the form's OnOpen property to CyclicCustomers.GotoFirst, the first command button will be selected when the form is opened, moving the focus to the last control on the form.

  4. On the Edit menu, click Tab Order.

  5. Scroll to the bottom of the list of control names to find the new btnGotoLast and btnGotoFirst controls. Select the btnGotoLast control and drag it to the top of the list. The btnGotoFirst control should remain at the bottom of the list.

  6. View the form in Form view. The first Customer ID in the Customers table is displayed.

  7. Press SHIFT+TAB. The Fax field (the last field in the form) is selected.

  8. Press TAB. The Customer ID field is selected.

REFERENCES

For more information about the Cycle property, search the Help Index for "cycle," or ask the Microsoft Access 97 Office Assistant.


Additional query words: circular
Keywords : FmsEvnt kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.