Clearing a record in a data entry form

  • Thread starter Thread starter daniwini
  • Start date Start date
D

daniwini

Guest
I've got a data entry form with macros controlling the usual data validation stuff. What I want is a way for the user to clear all the data he may have entered in error and get back to a clean sheet that will close without any msgboxes about null values, 'not being able to save at this time' etc.

Obviously, i can clear the sheet by setting the necessary values back to their old values or to null or whatever but the record will still throw up errors when it is updated/the form is closed etc because it thinks it has been changed and wants to save those changes.

Is there a simple way that I can avoid this and clear or close a half completed record in a form without either saving ant of the data or pesky user dialogues.

Hope someone can help

Thanks very much

daniwini
 
I think you are wanting the cancel/undo action. Create a Command Button, select 'Record Operations' and 'Undo Record'.

If you need to close the record at the same time, you can insert a Docmd.Close command in your code after the Undo Event. Alternatively, you can try DoCmd.Close ,,acSaveNo

Hope it helps..
 
Thanks Peter

Thanks very much Peter.

This is exactly what I wanted. I had been trying to do it with macros and failing dismally. I am not too hot on vB and had been trying to avoid it altogether - can you recommend a good book for vB in access?

Thanks again

Dan Winchester
 
Dan, glad to be of help.

I fairly new to VBA myself, and I don't really know what books are available.

There are some very talented guys who do a lot on this forum - hopefully they can can recommend some good material for us both.

Regards....Peter
 
Me.Undo will back out all unsaved changes to the current record.

Peter, the "acSaveNo" argument in the "DoCmd.Close ,,acSaveNo" statement refers to saving the active form. It has nothing to do with NOT saving the current record.
 
Pat, thanks for the tip re acSaveNo - I spent a fair bit of time on that recently and gave up in the end.
 

Users who are viewing this thread

Back
Top Bottom