I am trying to find a neat way to handle ESC key processing on a form. I would like ESC key to have two functions - when ESC is pressed in a form's non-empty control, I would like to just erase the control's contents. If ESC is pressed second time in a row, I would like to exit the form. Here's the functon I am calling in Key press event:
Public Sub gvEsc(key, frm)
If key = vbKeyEscape Then
If frm.ActiveControl <> Null Then
frm.ActiveControl = Null
DoCmd.Close acForm, frm.Name, acSaveNo
However this function closes the form immediatelly after the first hit of ESC.
Is there a solution without involving more than one event?
PS: more points to come for neat solution.