Does 'esc' key post an event?

  • Thread starter Thread starter jlh4u
  • Start date Start date
J

jlh4u

Guest
I have a data entry form and I'm trying to do one of the following:

- If the user prsses the 'esc' key after having changed data, post a msgbox message confirming that (s)he doesn't want to save the changes.
OR
- Disable the 'esc' key altogether and require the user to use a menu option to exit the form.

Haven't the first idea how to trap this. Help documentation doesn't. This Access2000. Any ideas?
 
This question has almost the same answer that I gave to Full_Williams.

In your Form's Preferences go to the Event Tab and change KeyPreview to Yes.
This will send any Key presses to the form itself.

Then for the form_KeyPress event you would test for the Esc key:

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
MsgBox "Do you want to erase your changes?"
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom