ToggleButton.OnKeyDown 属性 (Access)ToggleButton.OnKeyDown property (Access)

设置或返回在属性窗口中的键按下框的值。Sets or returns the value of the On Key Down box in the Properties window. 可读写 StringRead/write String.


expressionexpression. OnKeyDown

_表达式_一个代表ToggleButton对象的变量。expression A variable that represents a ToggleButton object.


该属性有助于以编程方式更改事件别触发时 Microsoft Access 所采取的行动。This property is helpful for programmatically changing the action 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.

当用户按某个键在窗体或控件获得焦点时,将发生KeyDown事件。The KeyDown event occurs when a user presses a key while a form or control has the focus. 如果您在窗体或控件使用 SendKeys 操作的宏或 Visual Basic 中的 SendKeys 语句发送击键,也会发生此事件。This event also occurs if you send a keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.

OnKeyDown值将为以下内容,具体取决于 (通过单击对象的属性窗口中的键按下框旁边的生成按钮来访问) 的选择生成器窗口中所选内容之一:The OnKeyDown value will be one of the following, depending on the selection chosen in the Choose Builder window (accessed by clicking the Build button next to the On Key Down box in the object's Properties window):

  • 如果选择表达式生成器,则值将为"=expression" ,where_expression_ 是表达式生成器窗口的表达式。If Expression Builder is chosen, the value will be "=expression ", where_expression_ is the expression from the Expression Builder window.

  • 如果选择了"宏生成器",则该值是宏的名称。If Macro Builder is chosen, the value is the name of the macro.

  • 如果选择了"代码生成器",则该值是"[事件过程]"。If Code Builder is chosen, the value will be "[Event Procedure]".

如果键按下框为空,属性值为空字符串。If the On Key Down box is blank, the property value is an empty string.


下面的示例打印"Order Entry"窗体上名为"OK"按钮立即窗口中的OnKeyDown属性的值。The following example prints the value of the OnKeyDown property in the Immediate window for the button named "OK" on the "Order Entry" form.

Debug.Print Forms("Order Entry").Controls("OK").OnKeyDown

另请参阅See also

切换按钮对象ToggleButton Object