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!

How do I abort a form entry and not get a new record?

Status
Not open for further replies.

wjmontague

Programmer
Jun 19, 2001
11
US
Sometimes I am in a form and need more informations so that I want to make the entry at a later time but I cannot quit without creating a new entry which is incomplete and I don't want to keep. How can I quit without saving the current record entry information?
 
If you click on the edit menu it will give you the option to undo the current field/Record
 
I need to have this undo or not save when I click on an abort button in the form. The user should just say I don't really want to make this entry so I am clicking the abort button and the record is not saved.
 
Two ways :

1. Watch the "Pencil" in the status bar to the far left of the form. As long as it is displayed, you can just hit escape and your record won't be saved. The minute it turns into a triangle, your record has been saved.

2. Use the "On Update" event of the form. Something simple would be:
Code:
Form_New Form on Update(cancel as boolean)
Dim msg
Dim Sty
Dim Resp
msg = "Do you want to save?"
Sty = vbYesNo
resp = msgbox(msg,sty)
if resp = vbYes then
Cancel = false
Else
Cancel = true
End Sub

 
on a command button place this code

DoCmd.RunCommand acCmdUndo

if not comfortable with that just use the wizard and under record operations there is a undo option it will create the code for you

good luck
 
I would suggest using two vb methods Dirty and undo
first check if the record has unsaved changes if it has allow the user to abort the changes. look up teh two methods in the help file.

if me.dirty then
me.undo
else
end if

 
The DoCmd.RunCommand acCmdUndo works great except that it still adds a blank record to the data base. I would prefer not to have this blank record.
 
I finally got it. Thanks for all your help.
On my command button in the form that says abort.
I have the code

DoCmd.RunCommand acCmdUndo
DoCmd.RunCommand acCmdClose

This does the trick no files added probably do not even need the undo but I'll try that later. Again thanks to all who helped me here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top