我想以某种形式在某些按钮上添加组合键盘快捷键(例如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的。
用于测试键的代码是正确的,但是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