Office中国论坛/Access中国论坛

标题: 大家帮帮我,如何引发键盘事件 [打印本页]

作者: kingingr    时间: 2006-5-9 19:03
标题: 大家帮帮我,如何引发键盘事件
我是菜鸟,但想学习。

我想用键盘来控制打开一个窗体

如:

此时我杂窗体1 想按F9进入到窗体2中

我已经写了宏openform类型,但是却不知道怎么让键盘相应。

大家帮帮我。

[em04][em04][em04]

[此贴子已经被作者于2006-5-9 11:03:44编辑过]


作者: 一点通    时间: 2006-5-9 19:16
可参考这个例子

http://www.office-cn.net/forum.php?mod=viewthread&tid=36313
作者: kingingr    时间: 2006-5-9 19:51
明白了。

谢谢。
作者: 方漠    时间: 2006-5-9 20:16
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF9 Then
   MsgBox "You have press key F9!"
End If

End Sub

*Note: pls set KeyPreview as "True".

A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3