Controlling the ESC key

kermit5

Registered User.
Local time
Today, 16:01
Joined
Nov 2, 2001
Messages
122
I have a form with a combo box with the OnKeyDown event with the following code:

me.MyComboBox.Dropdown

but I am having problems with the users inadvertantly changing this value while trying to navigate the form.

I am looking for a way to do one of two things.
1. change the OnKeyDown event to only drop down when the down or up arrow keys are pressed; or
2. have the record reset (or the changes undone) when the user presses a specific key (I'm thinking the ESC key).

Is there a reference chart somewhere showing me the value of the various key on the keyboard so I can create a series of Select-Case statements to control the effects of specific key strokes?

Any ideas?
 
Last edited:
The easiest way to figure out what keycode goes with what key is to try the following:

Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
'or Debug.Print KeyCode
End Sub
 
Access Help Keycode Constants
 
Keycode Constants in VB Help is exactly what I was looking for.
How do I write the code using vb...

For example, the the OnKeyDown event procedure
If ?????? = vbKeyDown Then
Do these Things

Or

Select Case ??????
Case vbKeyDown
Do this
Case vbKeyA thru vbKeyZ (is something like this possible so if any alpha key is pressed this case is true?)
Do this...

etc.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom