适用于
BoundObjectFrame 对象 |
Image 对象 |
OptionGroup 对象 |
SubForm 对象 |
CheckBox 对象 |
Label 对象 |
Page 对象 |
TabControl 集合 |
ComboBox 对象 |
Line 对象 |
PageBreak 对象 |
TextBox 对象 |
CommandButton 对象 |
ListBox 对象 |
Rectangle 对象 |
ToggleButton 对象 |
CustomControl 对象 |
ObjectFrame 对象 |
Report 对象 |
|
Form 对象 |
OptionButton 对象 |
Section 对象 |
用于存储 Microsoft Office Access 2007 应用程序所需的有关窗体、报表、数据访问页、节或控件的额外信息。 字符串型,可读/写。
表达式.Tag
表达式 必需。 返回“适用范围”列表中的对象之一的表达式。
备注
可输入最多包含 2048 个字符的字符串表达式。 默认设置为零长度字符串(" ")。
可使用对象的属性表、宏或 Visual Basic for Applications (VBA) 代码设置此属性。
与其他属性不同,Tag 属性设置不会影响对象的其他属性。
可使用此属性将标识字符串分配给对象,而不会影响任何其他属性设置或产生其他副作用。 需要检查作为变量传递给某过程的窗体、报表、数据访问页、节或控件的标识时,Tag 属性很有用。
示例
以下示例使用 Tag 属性来显示有关窗体上的控件的自定义信息。 当一个控件具有焦点时,在一个名为 lblMessage 的标签上将出现该控件的描述性文本。 可通过将每个控件的 Tag 属性设置为短文本字符串来指定消息文本。 当控件获得焦点时,其 Tag 属性分配给标签控件的 Caption 属性。 此示例显示窗体上一个名为 txtDescription 的文本框和一个名为 cmdButton 的命令按钮的描述性文本。
Sub Form_Load()
Dim frmMessageForm As Form
Set frmMessageForm = Forms!Form1
frmMessageForm!lblMessage.Caption = "" ' Clear text.
frmMessageForm!txtDescription.Tag = _
"Help text for the text box."
frmMessageForm!cmdButton.Tag = _
"Help text for the command button."
End Sub
Sub txtDescription_GotFocus()
' Tag property setting as caption.
Me!lblMessage.Caption = Me!txtDescription.Tag
End Sub
Sub txtDescription_LostFocus()
Me!lblMessage.Caption = ""
End Sub
Sub cmdButton_GotFocus()
' Tag property setting as caption.
Me!lblMessage.Caption = Me!cmdButton.Tag
End Sub
Sub cmdButton_LostFocus()
Me.lblMessage.Caption = " "
End Sub