Table of contents
TOC
折叠目录
展开目录

CommandButton.Click 事件 (访问)CommandButton.Click Event (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

当用户按下并在一个对象上释放鼠标按钮时, Click事件发生。The Click event occurs when the user presses and then releases a mouse button over an object.

语法Syntax

表达式单击expression. Click

表达式_一个表示命令按钮对象的变量。_expression A variable that represents a CommandButton object.

注解Remarks

  • 此事件适用于包含超链接的控件。This event applies to a control containing a hyperlink.

若要在该事件发生时运行宏或事件过程,请将OnClick属性设置为宏的名称或 [事件过程]。To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

对于控件,用户执行以下操作时发生此事件:For a control, this event occurs when the user:

  • 用鼠标左键单击控件。用右边或中间的鼠标键单击控件不会触发此事件。Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • 单击包含超链接数据使用鼠标左的按钮控件。用右边或中间的鼠标键单击控件不会触发此事件。当用户将鼠标指针移动包含超链接数据,鼠标指针将变为"手"形图标的控件。当用户单击鼠标键时,超链接将被激活,然后Click事件发生。Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • 通过按箭头键后再按 Enter 键,或通过单击鼠标按钮,在组合框或列表框中选择一项。Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • 当命令按钮、复选框、选项按钮或切换按钮具有焦点时按空格键。Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • 在命令按钮的默认值属性设置为是的窗体上按 ENTER 键。Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • 在命令按钮的Cancel属性设置为是的窗体上按 ESC 键。Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • 按下某个控件的访问键。例如,如果某个命令按钮的标题属性设置为&;转,按 ALT + G 会触发该事件。Presses a control's access key. For example, if a command button's Caption property is set to &;Go, pressing ALT+G triggers the event.

对于只命令按钮,Microsoft Access 运行宏或事件过程,当用户按下 ENTER 键或快捷键选择该命令按钮的OnClick属性指定。请将宏或事件过程运行一次。如果您希望命令按钮按下时反复运行的宏或事件过程,请AutoRepeat属性设置为是。对于其他类型的控件,您必须单击控件通过使用鼠标按钮来触发Click事件。For a command button only, Microsoft Access runs the macro or event procedure specified by the OnClick property when the user chooses the command button by pressing the ENTER key or an access key. The macro or event procedure runs once. If you want the macro or event procedure to run repeatedly while the command button is pressed, set its AutoRepeat property to Yes. For other types of controls, you must click the control by using the mouse button to trigger the Click event.

命令按钮的Click事件发生时选择该命令按钮。此外,如果您选择它时,命令按钮没有焦点,命令按钮的EnterGotFocus事件发生之前的Click事件。The Click event for a command button occurs when you choose the command button. In addition, if the command button doesn't already have the focus when you choose it, the Enter and GotFocus events for the command button occur before the Click event.

双击某个控件导致DblClick单击事件发生。对命令按钮而言,双击鼠标键将触发下列事件按以下顺序:Double-clicking a control causes both the DblClick and Click events to occur. For command buttons, double-clicking triggers the following events, in this order:

在 MouseDownMouseUp单击DblClick单击MouseDownMouseUpClickDblClickClick

通常情况下,将一个Click事件过程或宏附加到命令按钮以执行某些命令和类似命令的操作。其他适用的控件,使用此事件来触发操作以响应本主题前面所述的情况之一。Typically, you attach a Click event procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

可以在 DblClick 宏中使用CancelEvent操作取消的第二个Click事件。有关详细信息,请参阅 DblClick 事件主题。You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

若要区分的左边、 右边和中间的鼠标按钮,请使用MouseDownMouseUp事件。To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

另请参阅See also

概念Concepts

命令按钮对象CommandButton Object

© 2018 Microsoft