选项按钮. TabIndex 属性 (权限)OptionButton.TabIndex property (Access)

文本框的 TabIndex 属性可用于在窗体或报表上的 tab 键顺序指定控件的位置。You can use the TabIndex property to specify a control's place in the tab order on a form or report. Integer 型,可读/写。Read/write Integer.

语法Syntax

表达式TabIndexexpression.TabIndex

_表达式_一个代表**选项按钮** 对象的变量。expression A variable that represents an OptionButton object.

备注Remarks

可以将TabIndex属性设置为一个整数, 表示该控件在窗体的 tab 键次序中的位置。You can set the TabIndex property to an integer that represents the position of the control within the tab order of the form. 有效设置可以从 0 到总控件数减 1 的最后一个选项卡位置的第一个选项卡位置。Valid settings are 0 for the first tab position, up to the total number of controls minus 1 for the last tab position. 例如,如果某个窗体有三个每个具有 TabIndex 属性的控件,其有效的 TabIndex 属性设置是 0、 1 和 2。For example, if a form has three controls that each have a TabIndex property, valid TabIndex property settings are 0, 1, and 2.

将该 文本框的 TabIndex 属性设置为一个整数小于 0 产生错误。Setting the TabIndex property to an integer less than 0 produces an error.

默认情况下,Microsoft Access 为按顺序创建这些窗体上的控件指定 tab 键顺序。By default, Microsoft Access assigns a tab order to controls in the order that you create them on a form. 每个新控件都将排在 Tab 键次序表的最后。Each new control is placed last in the tab order. 如果将控件的TabIndex属性设置更改为调整 tab 键次序, 则 Access 会自动对其他控件的TabIndex属性设置进行重编号, 以反映插入和删除。If you change the setting of a control's TabIndex property to adjust the tab order, Access automatically renumbers the TabIndex property setting of other controls to reflect insertions and deletions.

在 "窗体" 视图中, 隐藏或禁用的控件保持在 tab 键次序中, 但在按 Tab 键时将被跳过。In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the Tab key.

更改窗体上其他控件的 Tab 键次序不会影响按下某个控件的访问键以后出现的情况。Changing the tab order of other controls on the form doesn't affect what happens when you press a control's access key. 例如, 如果已为文本框的标签创建了访问键, 则只要按下标签的访问键, 焦点就会移到文本框中, 即使您更改了该文本框的TabIndex属性设置也是如此。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.

如果您按某个控件 (如标签),没有 TabIndex 属性 (因而不在 tab 键次序中) 的访问键,焦点将移到下一个控件可以接收焦点的 tab 键顺序。If you press an access key for a control such as a label that doesn't have a TabIndex property (and thus isn't in the tab order), the focus moves to the next control in the tab order that can receive the focus.

示例Example

下面的示例翻转命令按钮和文本框的 tab 键次序。The following example reverses the tab order of a command button and a text box. 因为第一次创建 TextBox1,它的 TabIndex 属性设置为 0 并且 Command1 已设置为 1。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 = 1 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.