Article ID: 112064
Article Last Modified on 1/18/2007
APPLIES TO
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
- Microsoft Access 95 Standard Edition
- Microsoft Access 97 Standard Edition
This article was previously published under Q112064
Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
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 Cycle property only applies to controls in the Detail section of the form. 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.
Create a macro called CyclicCustomers with the following actions:
MacroName Action ----------------------- GotoFirst GotoControl GotoLast GotoControl GotoFirst Actions ------------------------ ControlName: Customer ID GotoLast Actions ---------------- ControlName: Fax
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.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.- On the Edit menu, click Tab Order.
- 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.
- View the form in Form view. The first Customer ID in the Customers table is displayed.
- Press SHIFT+TAB. The Fax field (the last field in the form) is selected.
- 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: kbhowto KB112064