assign a key to move cursor

S

SOS

I have a subform Calculate in a main form. I tried to use Shift+alter key +
key C to move cursor into the subform. In the caption of the subform label, I
put &Calculate. so that you can see C is underlined. In the program keydown,
I check alter + shift key to see if key "C" is pressed. However, it doesn't
work. Can someone help?
 
D

Douglas J. Steele

What does your code look like? When I tested just now, holding down the
Shift and Alt keys while pressing the C key resulted in KeyPress being 67
(which is C), and Shift being 5 (the combination of acShiftMask and
acAltMask). In other words, the following results in a message box with that
combination:

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

If KeyCode = 67 And Shift = 5 Then
MsgBox "You pressed C while holding the Alt and Shift keys"
End If

End Sub

To make it more obvious what the code's doing, you could use:

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

If KeyCode = Asc("C") And Shift = (acShiftMask + acAltMask) Then
MsgBox "You pressed C while holding the Alt and Shift keys"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top