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

設定或傳回在 [ 屬性 ] 視窗中的 [ On Click ] 方塊的值。Sets or returns the value of the On Click box in the Properties window. 可讀寫的 StringRead/write String.

語法Syntax

運算式OnClickexpression.OnClick

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.

註解Remarks

此屬性是很有用的以程式設計方式變更時觸發事件,Microsoft Access 所採取的動作。This property is helpful for programmatically changing the action that Microsoft Access takes when an event is triggered. 例如,在各個事件呼叫之間,您也許想要根據不同狀況下所引動的事件,來改變運算式的參數,或是從事件程序轉換到運算式或是巨集。For example, between event calls you may want to change an expression's parameters, or switch from an event procedure to an expression or macro, depending on the circumstances under which the event was triggered.

Click 事件發生於以下任何情況發生時:The Click event occurs when one of the following things occurs:

  • 使用者按下及放開滑鼠左鍵下拉式方塊。The user presses and releases the left mouse button over a combo box.
  • 使用者會認可變更下拉式方塊的值。The user commits a change to the value of the combo box. 在此例中 AfterUpdate 事件之後和 Exit 事件之前就會引發 Click 事件。In this case, the Click event fires after the AfterUpdate event and before the Exit event.

OnClick值會是下列其中一個下列命令,根據 [選擇建立器] 視窗中 (藉由選擇物件的 [屬性] 視窗中] 方塊旁邊按一下[建立] 按鈕來存取):The OnClick value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by choosing the Build button next to the On Click box in the object's Properties window):

  • 如果您選擇 [運算式建立器],值會是 =運算式,其中_expression_是來自 [運算式建立器] 視窗的運算式。If you choose Expression Builder, the value will be =expression, where expression is the expression from the Expression Builder window.

  • 如果您選擇巨集建立器,值會是巨集的名稱。If you choose Macro Builder, the value is the name of the macro.

  • 如果您選擇程式碼建立器,值會是 [Event Procedure]。If you choose Code Builder, the value will be [Event Procedure].

如果 [On Click] 方塊是空白的,此屬性值為空字串。If the On Click box is blank, the property value is an empty string.

範例Example

下列範例會建立關聯的Click事件與順序項目表單上名為 [確定] 按鈕OK_Click事件程序如果目前沒有關聯。The following example associates the Click event with the OK_Click event procedure for the button named OK on the Order Entry form, if there is currently no association.

With Forms("Order Entry").Controls("OK") 
 If .OnClick = "" Then 
 .OnClick = "[Event Procedure]" 
 End If 
End With 

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