Tag Property

Applies To

Bound Object Frame Control, Chart Control, Check Box Control, Combo Box Control, Command Button Control, Form, Form Section, Image Control, Label Control, Line Control, List Box Control, Option Button Control, Option Group Control, Page Break Control, Rectangle Control, Report, Report Section, Text Box Control, Toggle Button Control, Unbound Object Frame Control.

Description

You can use the Tag property to store any extra information about a form, report, section, or control needed by your application.

Setting

You can enter a string expression up to 2048 characters long. The default setting is a zero-length string (" ").

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

Remarks

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. 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.

See Also

Name Property.

Example

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.


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."Sub
txtDescription_GotFocus()
    Me!lblMessage.Caption = Me!txtDescription.Tag    ' Tag property as
                                                    ' caption.Sub
txtDescription_LostFocus()
    Me!lblMessage.Caption = ""Sub
cmdButton_GotFocus()
    Me!lblMessage.Caption = Me!cmdButton.Tag            ' Tag property as
                                                    ' caption.Sub
cmdButton_LostFocus()
    Me.lblMessage.Caption = " "Sub