ESC key pressed... what happens next?

BrettM

just a pert, "ex" to come
Local time
Tomorrow, 05:46
Joined
Apr 30, 2008
Messages
134
Can anyone inform me of a way to action a subroutine AFTER the ESC key has been pressed and the Undo has been actioned?

I do not mean a call from the "On Undo" event as this happens prior to the actual Undo action.

I have a number of calculations that happen after a field value changes and displays the total for the user. If the ESC key is pressed, then the field value is reset however the total is not.

I would prefer not to use the form timer event if possible.

Regards Brett
 
Just an idea.

Open an empty hidden form with the esc key On Key Up. Close this form with its timer and run your procedure with its On Close event.

This avoids using the timer event on the real form which I expect you are avoiding because it would be going off continuously.
 
Can anyone inform me of a way to action a subroutine AFTER the ESC key has been pressed and the Undo has been actioned?

I do not mean a call from the "On Undo" event as this happens prior to the actual Undo action.

I have a number of calculations that happen after a field value changes and displays the total for the user. If the ESC key is pressed, then the field value is reset however the total is not.

I would prefer not to use the form timer event if possible.

Regards Brett

Have you looked into trying the form's On Current event?
 
Have you looked into trying the form's On Current event?
..sure have however I am doing lots of other stuff there.

I actually took GalaxiomAtHome's idea and ran with it. The result is a small borderless form called "fmCancel" that pops up saying "Cancelling". It then does the stuff I require. Was a neat suggestion GalaxiomAtHome. Thanks. The scales have been weighed in your favour.

The form's Timer interval is set to 1 and the "On Timer" event does this...
Code:
Private Sub Form_Timer()
    Me.TimerInterval = 0
    Call SommitToDoHere
    Call SommitElseToDoHere
    Forms!Master!Subform.Form.tbHidden.SetFocus ' Small invisible field
    DoCmd.Close acForm, "fmCancel", acSaveNo
End Sub

Posted for others to benefit.
 
By the way Brett - just as a side note -

If this code is for the form that has the timer:

DoCmd.Close acForm, "fmCancel", acSaveNo

Then you can use the more generic version (which means you can copy and paste it on ANY form and it will work:

DoCmd.Close acForm, Me.Name, acSaveNo

if you use it as is with the Me.Name part, it can be used on any form, as is, and you never have to specifically give the form name. :)
 

Users who are viewing this thread

Back
Top Bottom