Table of contents
TOC
折叠目录
展开目录

CustomControl.Tag 属性 (访问)CustomControl.Tag Property (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

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

语法Syntax

表达式标记expression. Tag

表达式_一个表示CustomControl对象的变量。_expression A variable that represents a CustomControl 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.

可以使用此属性可为对象指定一个标识字符串,而不影响任何其他属性设置或产生其他副作用。当您需要检查窗体、 报表、 节或作为变量传递给过程的控件的标识时, Tag属性是非常有用。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. 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属性来显示有关窗体上的控件的自定义信息。当一个控件具有焦点时,描述性文本显示在标签控件调用lblMessage。您可以通过将每个控件的Tag属性设置为一个简短文本字符串来指定消息的文本。当某一控件获得焦点时,其Tag属性分配给该标签控件的标题属性。本示例显示名为的文本框中的说明性文字txtDescription和一个命令按钮,名为cmdButton在窗体上。The following example uses the Tag property to display custom messages about controls on a form. 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. When a control receives the focus, its Tag property is assigned to the label control's Caption property. 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

概念Concepts

CustomControl 对象CustomControl Object

© 2018 Microsoft