[VBA Access 2010组合键按下事件

问题描述 投票:0回答:1

我想以某种形式在某些按钮上添加组合键盘快捷键(例如Alt + 1),但是不确定如何精确地做到这一点。这是我到目前为止所拥有的:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

 Select Case KeyCode

    Case (KeyCode = vbKey2) And (Shift And acAltMask > 0)
        Form_sbfrmSalesOrder_LineItem.cmdNew_Click

    'Other Cases..

End sub

请记住,这是针对vba Access 2010的。

vba ms-access
1个回答
0
投票

用于测试键的代码是正确的,但是Select Case语句的格式不正确。

您的代码应为:

   Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    Select Case KeyCode   
    Case vbKey2
       If Shift And acAltMask > 0 Then
          Form_sbfrmSalesOrder_LineItem.cmdNew_Click
       End If
    'Other Cases..
    Case vbKey3
    .... 
   End sub
© www.soinside.com 2019 - 2024. All rights reserved.