TextBox.Tag 属性 (Access)TextBox.Tag property (Access)

存储有关窗体、 报表、 节或控制一个 Microsoft Access 应用程序所需的额外信息。Stores extra information about a form, report, section, or control needed by a Microsoft Access application. 读/写 StringRead/write String.

语法Syntax

expressionexpression. Tag

expression:表示 TextBox 对象的变量。expression A variable that represents a TextBox object.

说明Remarks

可以为该属性输入一个长达 2048 个字母的字符串表达式。You can enter a string expression up to 2048 characters long. 默认设置是零长度字符串(" ")。The default setting is a zero-length string (" ").

与其他属性, Tag属性设置不会影响的对象的属性。Unlike other properties, the Tag property setting doesn't affect any of an object's attributes.

可以使用此属性可为对象指定一个标识字符串,而不影响任何其他属性设置或产生其他副作用。You can use this property to assign an identification string to an object without affecting any of its other property settings or causing other side effects. 如果您需要检查窗体、 报表、 部分中或作为变量传递到过程的控件的标识, Tag属性很有用。The Tag property is useful when you need to check the identity of a form, report, section, or control that is passed as a variable to a procedure.

示例Example

下面的示例使用Tag属性来显示有关窗体上控件的自定义消息。The following example uses the Tag property to display custom messages about controls on a form. 当一个控件具有焦点时,描述性文本显示在名为 lblMessage的标签控件中。When a control has the focus, descriptive text is displayed in a label control called lblMessage. 通过将每个控件的标记属性设置为短文本字符串指定邮件的文本。You specify the text for the message by setting the Tag property for each control to a short text string. 当某一控件获得焦点时,其 Tag 属性分配给该标签控件的 标题 属性。When a control receives the focus, its Tag property is assigned to the label control's Caption property. 本示例显示一个名为 txtDescription的文本框和一个名为 cmdButton在窗体上的命令按钮的描述文本。This example displays the descriptive text for a text box named txtDescription and a command button named cmdButton on a form.

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

另请参阅See also

TextBox 对象TextBox Object