TabIndex Property

Applies To

Bound Object Frame Control, Check Box Control, Combo Box Control, Command Button Control, List Box Control, Option Button Control, Option Group Control, Subform/Subreport Control, Text Box Control, Toggle Button Control, Unbound Object Frame Control.

Description

You can use the TabIndex property to specify a control’s place in the tab order on a form.

Note The TabIndex property applies only to controls on a form.

Setting

You can set the TabIndex property to an integer representing the position of the control within the tab order of the form. Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

Setting the TabIndex property to an integer less than 0 produces an error.

You can set this property using the control’s property sheet, a macro, or Visual Basic.

Remarks

By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. Each new control is placed last in the tab order. If you change the setting of a control’s TabIndex property to adjust the tab order, Microsoft Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

Changing the tab order of other controls on the form doesn’t affect what happens when you press a control’s access key. For example, if you’ve created an access key for the label of a text box, the focus will move to the text box whenever you press the label’s access key — even if you change the TabIndex property setting for the text box.

If you press an access key for a control that doesn’t have a TabIndex property, the focus moves to the next control in the tab order that can receive the focus.

See Also

AutoTab Property, TabStop Property.

Example

The following example reverses the tab order of a command button and a text box. Because Textbox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.


Sub Form_Click()
    Me![Command1].TabIndex = 0
    Me![TextBox1].TabIndex = 1Sub