From: Dennis on
Hi,

I'm on Access via Xp Office Pro running XP Pro with SP3.

Quick question:

What is the KeyCode for the Escape key in the KeyDown or KeyPress events?
Also, is there a list of all KeyCodes somewhere?


Detail behind the question:



I have created a Calendar control that is working fine. Here is the code I
used:

Private Sub cboWorkDate_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.ocxCalWorkDt.Visible = True ' Make the calendar
visible
Me.ocxCalWorkDt.SetFocus ' Set focus on the
calendar
If IsNull(cboWorkDate) Then
Me.ocxCalWorkDt.Value = Date ' Set Calendar Start
Date to today
Else
Me.ocxCalWorkDt.Value = Me.cboWorkDate ' Set Calendar Start
Date to Work Date
End If
End Sub

Private Sub ocxCalWorkDt_Click()
Me.cboWorkDate.Value = Me.ocxCalWorkDt.Value ' Get the date the user
choose in the calendar
Me.cboWorkDate.SetFocus ' Set focus back on the
work date field
Me.ocxCalWorkDt.Visible = False ' Make the calendar
disappear
End Sub


When I click on the Work Date combo box, the calendar appears. When I click
on a date, the date is returned and the calendar disappears.

However, when I hit the Escape key the calendar does not appear. So I'm
guessing that I will have to code that part.


I have created a subroutine called:

Private Sub ocxCalWorkDt_KeyDown(KeyCode As Integer, ByVal Shift As Integer)

If keyCode = ???? Then
me.ocxCalWorkDate.Visible = False
me.cobWorkDate.SetFocus
end if
End Sub

I'm looking for a list off all keycodes for KeyDown event.



--
Dennis
From: Dennis on
All,

I found my answer. I should have waited a few more mintues before I posted.
Sorry about that.

For other,

The escape key keycode is vbKeyEscape - a vb constant.

For list of key codes - type Keycode Constants in VBA Help.

Dennis


From: Stuart McCall on
"Dennis" <Dennis(a)discussions.microsoft.com> wrote in message
news:4A66D9FE-F059-4A06-851B-9C3DF286F263(a)microsoft.com...
> All,
>
> I found my answer. I should have waited a few more mintues before I
> posted.
> Sorry about that.
>
> For other,
>
> The escape key keycode is vbKeyEscape - a vb constant.
>
> For list of key codes - type Keycode Constants in VBA Help.
>
> Dennis

If ever you want to do a table-driven version, simply save the following to
a text file, then import it.

1,"A",65
2,"B",66
3,"C",67
4,"D",68
5,"E",69
6,"F",70
7,"G",71
8,"H",72
9,"I",73
10,"J",74
11,"K",75
12,"L",76
13,"M",77
14,"N",78
15,"O",79
16,"P",80
17,"Q",81
18,"R",82
19,"S",83
20,"T",84
21,"U",85
22,"V",86
23,"W",87
24,"X",88
25,"Y",89
26,"Z",90
27,"0",48
28,"1",49
29,"2",50
30,"3",51
31,"4",52
32,"5",53
33,"6",54
34,"7",55
35,"8",56
36,"9",57
37,"NumPad_0",96
38,"NumPad_1",97
39,"NumPad_2",98
40,"NumPad_3",99
41,"NumPad_4",100
42,"NumPad_5",101
43,"NumPad_6",102
44,"NumPad_7",103
45,"NumPad_8",104
46,"NumPad_9",105
47,"NumPad_Multiply",106
48,"NumPad_Add",107
49,"NumPad_Enter",108
50,"NumPad_Subtract",109
51,"NumPad_Decimal",110
52,"NumPad_Divide",111
53,"F1",112
54,"F2",113
55,"F3",114
56,"F4",115
57,"F5",116
58,"F6",117
59,"F7",118
60,"F8",119
61,"F9",120
62,"F10",121
63,"F11",122
64,"F12",123
65,"F13",124
66,"F14",125
67,"F15",126
68,"Backspace",8
69,"Tab",9
70,"Clear",12
71,"Enter",13
72,"Esc",27
73,"Spacebar",32
74,"Page_Up",33
75,"Page_Down",34
76,"End",35
77,"Home",36
78,"Left_Arrow",37
79,"Up_Arrow",38
80,"Right_Arrow",39
81,"Down_Arrow",40
82,"Insert",45
83,"Delete",46
84,";",186
85,"=",187
86,"+",188
87,"-",189
88,".",190
89,"/",191
90,"'",192
91,"[",219
92,"\",220
93,"]",221
94,"#",222
95,"`",223

And the shift keys go like this:

1,"SHIFT +"
2,"CTRL +"
3,"SHIFT + CTRL +"
4,"ALT +"
5,"SHIFT + ALT +"
6,"CTRL + ALT +"


From: Dennis on
Stuart

Very cool. Thanks for the information.


--
Dennis