close and do not save

D

Dave

Access 2003
Data entry Form

if they put in "some data" then decide againse saving the record I have used
this code on a button:

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close

HOWEVER:
If they enter nothing and try to cancel I get an error something like "Undue
not avaiable"

How can I fix this.

Thanks much

Dave
 
A

Allen Browne

Test the Dirty property of the form to see if it needs to be undone or not:

If Me.Dirty Then Me.Undo
DoCmd.Close acForm, Me.Name
 
D

Dave

Thank you again,

dave

Allen Browne said:
Test the Dirty property of the form to see if it needs to be undone or
not:

If Me.Dirty Then Me.Undo
DoCmd.Close acForm, Me.Name
 
Top