Abandon New Record

  • Thread starter Thread starter Lou Burgoyne
  • Start date Start date
L

Lou Burgoyne

I want to capture when the user abandons the creation of a new record by
pressing the escape key.
Using the KeyDown event does not really do what I want becasue pressing ESC
does not always abandon the new record creation. It can also be used to
abandon the data being entered in a field on the form.

Any ideas would be greatly appreciated.

Lou Burgoyne
 
Use the Undo event of the Form.

This kind of thing:

Private Sub Form_Undo(Cancel As Integer)
If Me.NewRecord Then
Debug.Print "New record cancelled in form " & Me.Name & " at " &
Now()
End If
End Sub
 
Allen,

Thanks,

That was what I was looking for. It then leads me to a new question.
When the user starts entering a new record and then abandons it, I'd like
the form to show the last record in the form (which is currently sorted by
OrderNo).
"DoCmd.GoToRecord acDataForm, "frmJobOrder", acLast" leaves me on the
new record screen with none of the default values populated.
"DoCmd.GoToRecord acDataForm, "frmJobOrder", acPrevious" fails. Any
thoughts on how to display the last record in the form after a new record is
abandoned?

Thanks again.
 
If you are at the new record, then going to the previous one should take you
back (if there is one.)

Haven't tried though: you may find that you can't move record until after
Form_Undo has finished running.
 
Back
Top