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. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
#14
|
|||
|
|||
How Best to Disable ESC Key on Form
|
|
Thread Tools | |
Display Modes | |
|
|