Abandon New Record

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
 
A

Allen Browne

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
 
L

Lou Burgoyne

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.
 
A

Allen Browne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top