Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent ESC key from working as undo 4

Status
Not open for further replies.

psehudson

Programmer
Jan 30, 2008
9
US
I've created a form in Access 2000 that I use for entering RMA information. When I open the form, I create a new record in the table and assign the RMA based off the ID key number. I display the RMA number in a text box on the form. I've noticed that if the user goes to any text box on my form and presses ESC twice, all info on the screen (for example, the RMA number display) will go blank! Best that I can tell, it appears that the undo command is being run when ESC is pressed. Is there a way to remap ESC so that it will not do this? I've tried adding the following code "On Key Down" event

Code:
Private Sub cb_phone_lookup_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = 27 Then KeyCode = 0
    
End Sub

This works, but I must add this to every text box, combo box, etc. on my form. Is there an easier way to do this?


Also, I've noticed that I can no longer run the "delete record" command after ESC has been pressed twice.

Code:
' delete record
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70


Why is this?

Thanks in advance!
 
Chances are that if the user is pressing ESC multiple times this is exactly the behaviour they want. I know that when I'm in an unfamiliar program and I want to back out from a mistake, the first thing I try is the ESC. So I'm just wondering if you wouldn't want to keep this standard behaviour after all?

 
I don't mind the undo function except that it has the undesired side effect of wiping out any text I manually program into the form when it opens (the RMA number). The RMA number is fixed, so it should never change and certainly should not be cleared when I press ESC. If I keep the ESC active, how can I prevent the RMA text from being deleted?

Yes, I tried adding my code to the "on key down" of the form, but it doesn't respond when I press ESC in my text boxes.
 
The "On key down" event of my form doesn't appear to be working. I just entered a very simple event

Code:
dim x as integer

x = 1

and set a breakpoint on the event, but it never gets called when I press a key. Is there another setting that may prevent this event from occuring?
 
When using the KeyDown event at the form level, you have to set the form's Key Preview Property to Yes.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
That fixed it! Thanks very much to all of you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top