A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How Best to Disable ESC Key on Form



 
 
Thread Tools Display Modes
  #11  
Old March 11th, 2010, 02:53 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default How Best to Disable ESC Key on Form

Try moving the code to the KeyDown event instead of the KeyUp event. Doing
that seems to work for me. Evidently the undo takes place before the keyup
event occurs.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
If MsgBox(" Do you want to CLEAR changes?", _
vbExclamation + vbOKCancel, _
"ESC Key Hit... What?") = vbCancel Then
KeyCode = 0 'Cancel the key stroke
End If
End If
End Sub


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

MJ wrote:
John,

Your reply did get me "closer" to the the results I was looking for, but not
quite there yet.

1) Your code for SR KeyUP with modification for msgbox...

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
'Debug.Print "Escape key pressed"
If MsgBox(" Do you want to CLEAR changes?", vbExclamation +
vbOKCancel, "ESC Key Hit... What?") = vbCancel Then
KeyCode = 0 'Cancel the key stroke
End If
End If
End Sub

... it recognized that ESC key was hit and got me to the msgbox
question, but it DID NOT prevent clearing of data already entered into the
form.

2) Preventing the clearing of data entry is PARAMOUNT, so do you have any
suggestions on how to do that?

Thanks again for the help.

  #12  
Old March 11th, 2010, 10:23 PM posted to microsoft.public.access
mj
external usenet poster
 
Posts: 258
Default How Best to Disable ESC Key on Form

John,

That was it exactly!

I came to the same conclusion this morning after looking a little deeper
after reviewing your earlier inputs against JMs. Already have the change in
place ready for release at COB this evening.

Thanks again for your inputs they helped out greatly!

--

MJ


"John Spencer" wrote:

Try moving the code to the KeyDown event instead of the KeyUp event. Doing
that seems to work for me. Evidently the undo takes place before the keyup
event occurs.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
If MsgBox(" Do you want to CLEAR changes?", _
vbExclamation + vbOKCancel, _
"ESC Key Hit... What?") = vbCancel Then
KeyCode = 0 'Cancel the key stroke
End If
End If
End Sub


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

MJ wrote:
John,

Your reply did get me "closer" to the the results I was looking for, but not
quite there yet.

1) Your code for SR KeyUP with modification for msgbox...

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
'Debug.Print "Escape key pressed"
If MsgBox(" Do you want to CLEAR changes?", vbExclamation +
vbOKCancel, "ESC Key Hit... What?") = vbCancel Then
KeyCode = 0 'Cancel the key stroke
End If
End If
End Sub

... it recognized that ESC key was hit and got me to the msgbox
question, but it DID NOT prevent clearing of data already entered into the
form.

2) Preventing the clearing of data entry is PARAMOUNT, so do you have any
suggestions on how to do that?

Thanks again for the help.

.

  #13  
Old March 13th, 2010, 05:32 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default How Best to Disable ESC Key on Form


"MJ" wrote in message
...
My problem surrounds the ESC key function by design within Access. In
my
office we have a major departmental database being accessed by 20-30 users
at
any given time.
1. This is NOT an issue of the number of simultaneous users.
2. It IS a problem of users ACCIDENTALLY hitting ESC ocassionally
while they are entering data into this database.
+ The users are using this database and another commercial
database
(non-Access, which has different functional use for the ESC
key
than in Access) toggling back and forth between these
databases.

While my director would like the ESC disabled for this database, I am
thinking that I might be better if we were able to "fix" the real issue by
disabling it on select forms, one at a time as needed.

One user suggested that it might be useful to have a "check" message box
seeking the user's confirmation BEFORE clearing in the event the ESC key
is
hit. If the user does NOT confirm, then data remains as entered.

What would be the BEST way to approach this fix?

Thank you in advance for your assistance.

--

MJ


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.