Cancel feature

Dave31

Registered User.
Local time
Today, 17:09
Joined
Oct 11, 2006
Messages
68
Hi

After looking through the forums, i couldn' really see the answer i was looking for.
I have a form, that users can enter in details (with an auto-number created which is assigned to each record). Once they have entered the detials, theres a 'save' button which will save the record - which is fine. I also have a 'return' button which should return to the previous form and doesnt save the record. But as it stands, the record is saved when i click this return button. How do i make it so that the record isnt saved untill the save button is clicked? so if i return from the screen (pressing the return button), the record isnt saved (i.e. a cancel button).

Thanks in advance :)
 
This may be what you are looking for:

http://www.microsoft.com/office/com...ffice-access&lang=en&cr=US&sloc=en-us&m=1&p=1

'69 Camaro 8/12/2004 1:25 PM PST

It would probably be best if you could train your users to use the <ESC>
key, but if you want to put some code behind a button to prevent the
addition of a new record or changes to an existing record, then I would
recommend using the "Undo" method of the form. The syntax is:

Me.Undo

The SendKeys command isn't always reliable, since the window focus can
change at unexpected times, causing the simulated keystrokes may be
delivered to the wrong program. However, if you'd like to see the syntax,
here it is:

SendKeys "{ESC}{ESC}", False

HTH.

Gunny
 
Try my attachment. This is a stripped down version of a database I wrote for my company, so users could keep track of RMAs (Returned Merchandise).

Try to add a new RMA and you'll see my coding at work. A user cannot add a new record until the one they are currently adding is saved. They cannot save until they have completed all of the necessary fields and clicked save. They cannot exit back to the main menu without first deleting or saving an unfinished RMA. Have a play with it and see if it fits your needs.

*NB: This database was written under Access 2003, so needs some of the newer object libraries. It may not function properly under earlier Access versions.
 

Attachments

if you are using a bound form, you dont need a SAVE button. Any data you enter is automatically saved, which is what is happening. Ther only cicumstance that this wouldnt happen is if the record entry was incomplete and some reuired data (ie cannot be null in the table definition) was not entered. In that case you would get an "Access cannot save this record at this time" error.

If you use an unbound form, then you need the save button.

depends on what you want to do
 

Users who are viewing this thread

Back
Top Bottom