ComboBox.Tag 屬性 (Access)

儲存表單、 報表、] 區段或控制項的 Microsoft Access 應用程式所需的額外資訊。 讀取/寫入的 String

語法

運算式標記

表達 代表 ComboBox 物件的變數。

註解

您可以輸入最多為 2048 個字元長的字串運算式。 預設的設定是零長度字串 (" ")。

像其他屬性,它 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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應