ComboBox.DblClick 事件 (Access)ComboBox.DblClick event (Access)

Dblclick 發生於使用者按下及放開滑鼠左鍵兩次時間限制之內系統的物件時。The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

語法Syntax

運算式DblClick取消expression.DblClick (Cancel)

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

參數Parameters

名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
CancelCancel 必要Required IntegerInteger 設定決定是否發生 DblClick 事件。The setting determines if the DblClick event occurs. _Cancel_引數設定為True (1) 會取消DblClick事件。Setting the Cancel argument to True (1) cancels the DblClick event.

註解Remarks

表單上使用者按兩下的空白區域或記錄選取器的表單上發生 DblClick 事件。On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form. 控制項,則會發生於使用者按兩下控制項或表單檢視中的其標籤。For a control, it occurs when the user double-clicks a control or its label in Form view. 當使用者按兩下表單或控制項,但前之結果的按兩下動作 (例如之前發生 Microsoft Access 會在插入點是在文字方塊中的字詞) 會發生 DblClick 事件。The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

此事件不會套用至] 核取方塊、 選項按鈕或切換按鈕選項群組中。This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. 它只適用於選項群組本身。It applies only to the option group itself.

此事件不適用於附加到另一個控制項的標籤,例如文字方塊的標籤。This event doesn't apply to a label attached to another control, such as the label for a text box. 它只適用於「獨立式」標籤。It applies only to "freestanding" labels. 按兩下附加標籤的效果與按兩下關聯控制項的效果相同。Double-clicking an attached label has the same effect as double-clicking the associated control. 控制項的一般事件發生,但不是能以任何附加標籤的事件。The normal events for the control occur, but not any events for the attached label.

若要發生此事件時執行巨集或事件程序,請將**OnDblClick** 屬性設為巨集的名稱或 [事件程序]。To run a macro or event procedure when this event occurs, set the OnDblClick property to the name of the macro or to [Event Procedure].

如果是控制項,按兩下的結果取決於控制項。For controls, the result of double-clicking depends on the control. 例如,在文字方塊中的文字上按兩下會選取整個字。For example, double-clicking a word in a text box selects the entire word. 按兩下含有 OLE 物件的控制項會啟動建立該物件的應用程式,並且可以開始編輯物件。Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

如果 DblClick 事件不會發生系統的按兩下時間限制內,表單、 表單區段或控制項可辨識,而不是單一的 DblClick 事件的兩個 Click 事件。If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event. 時間限制之內取決於按兩下速度] 下的 Windows [控制台] 的 [滑鼠] 選項的 [按鈕] 索引標籤上的設定。The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of the Windows Control Panel.

DblClick 事件發生時執行巨集或事件程序,您可以開啟的視窗或文件按兩下圖示時。By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

按兩下控制項會使 按一下DblClick 事件發生。Double-clicking a control causes both Click and DblClick events to occur. 如果您按兩下、 輸入 及控制項的 GotFocus 事件之前 按一下DblClick 事件發生時將控制項上還沒有焦點。If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

如果是接收滑鼠事件的物件,事件的發生順序如下:For objects that receive mouse events, the events occur in this order:

MouseDownMouseUp按一下DblClickMouseDownMouseUpClickDblClick

當您按兩下命令按鈕時,會依照下列順序發生這些事件:When you double-click a command button, the following events occur in this order:

MouseDown (name) → MouseUp (name) →按一下DblClick (name) → MouseUp按一下MouseDownMouseUpClickDblClickMouseUpClick

按一下第二個可能會有任何影響 (例如,如果 按一下 [ 巨集或事件程序開啟強制回應對話方塊中的第一個 Click 事件的回應)。The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). 若要避免執行第二個按一下 [ 巨集或事件程序,放入DblClick巨集的 CancelEvent 巨集指令或DblClick事件程序中使用 [取消] 引數。To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro, or use the Cancel argument in the DblClick event procedure. 請注意,一般而言,應鼓勵按兩下命令按鈕。Note that, generally speaking, double-clicking a command button should be discouraged.

若您按兩下命令按鈕以外的任何其他控制項,第二個 Click 事件不會發生。If you double-click any other control besides a command button, the second Click event doesn't occur.

範例Example

下列範例顯示如何使用 DblClick 事件程序來開啟表單,顯示下拉式方塊的資料列來源資料表的記錄。The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box. 當使用者按兩下Salesperson下拉式方塊在Orders表單中的時,會顯示 [員工] 表單,顯示下拉式方塊中選取該員工的記錄。When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

若要嘗試此範例,請將下列事件程序新增至名為Orders包含名為EmployeeID的下拉式方塊的表單。To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID. 下拉式方塊應該具有其資料列來源相同的資料表是 [員工] 表單 (或源於該資料表的查詢) 的來源。The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

Private Sub EmployeeID_DblClick(Cancel As Integer) 
 DoCmd.OpenForm "Employees", , , _ 
 "EmployeeID = Forms!Orders!EmployeeID" 
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.