ComboBox.Tag 屬性 (Access)ComboBox.Tag property (Access)

儲存表單、 報表、] 區段或控制項的 Microsoft Access 應用程式所需的額外資訊。Stores extra information about a form, report, section, or control needed by a Microsoft Access application. 可讀寫 的字串Read/write String.

語法Syntax

運算式標記expression.Tag

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox 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. 您指定的文字訊息將每個控制項的 Tag 屬性設定為簡短的文字字串。You specify the text for the message by setting the Tag property for each control to a short text string. 當控制項收到焦點時,其 Tag 屬性會指派給此標籤控制項的 Caption 屬性。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

支援和意見反應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.