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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo a New Record

Status
Not open for further replies.

shwin

Programmer
Jun 10, 2004
15
US
Hey guys,

I have a general question about Access. When the user creates a new record, is there a back button that will undo this new record.
To elaborate, the user has not entered any data into this new record and clicking on the "Go To Previous" button has no effect.
Any help about Undo-ing a new record would be helful!

Thanks!
 
If your form is bound to a table, you just need to:

Me.Undo

If you are using standard navigation buttons, you'll have to replace them with custom buttons. And, if the record SHOULD be saved, you'll have to add logic to ask the User whether to save or Undo...



HTH,
Bob [morning]
 
shwin
You should be able to include a command button on your form, and behind the command button put
Me.Undo

You may or may not wish to include a message box asking the user whether or not they wish to exit the form, or continue with another entry (to accomodate hitting the Undo button in error)

Here is code, an example only of what I have behind an Undo button on an Interest form...
Code:
Dim intAnswer As Integer
If Me.InterestCharge = 0 Then
intAnswer = MsgBox("No Interest or NSF charge has been entered!" & Chr(13) & Chr(10) & "     Record will not be saved." & Chr(13) & Chr(10) & "Do you wish to make another entry?", vbYesNo + vbQuestion, "No entry")
Select Case intAnswer
    Case vbYes
    MsgBox "Thank you. Continue with your entry.", vbOKOnly, "Entry process continuing"
    Me.Undo
    Me.CamperID.SetFocus
    Case vbNo
    MsgBox "Thank you. Form will now close.", vbOKOnly, "Closing Interest / NSF form"
    Me.Undo
    DoCmd.Close acForm, "frmInterest"
    End Select
End If

By the way, hitting the <Esc> key will also reverse the most recent activity.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top