Write record only when you click save

jibb

Registered User.
Local time
Today, 13:29
Joined
Dec 1, 2011
Messages
93
Hello,

I have got a form for entering purchase orders, but I only want it to save the record if you click a save button. It would also be good to have a cancel button and, when closing the form if it isn't saved, a prompt to save or cancel the record.

I have seen a couple of posts about this but no clear answers...
 
I think the only way to do this is to use an unbound form instead of a bound form. With a bound form, closing the form, switching fields etc... will all trigger a save. If you used an unbound form for people to input the data, then created a save procedure that inserted a new record into your table with the values in your form controls, you could prevent the auto-creation of a new record and give the option for clearing/resetting the form.
 
Thanks,

How would you create that save procedure?
 
I think it would be easier to leave the it as a bound form.
Write a bit of code in the Unload event of the form that opens a message box asking the user if the record is to be saved. If the user replies “No”, then use Me.Undo to abandon the changes.
 
Thanks,

How can I set the form so that users can't navigate away from the current record?

Could you also give me an example of the unload code - I haven't done much code...
 
But the Before Update fires before the form is unloaded.

You can create a SAVE button which the user will click when he/she wants to save. The Before Update event will not fire if the SAVE button is clicked but the Before Update event will fire if it wasn't done via the SAVE button. So in essence, when you close the form it will fire.
 
rather than unbound form, i would bind the purchase order to a temporary table.

if you click save, then append the temp table to the main table. if not you don't need to do anything.

I reckon doing it this way gives you all the benefits of bound forms - which I think are easier to manage than unbound.
 

Users who are viewing this thread

Back
Top Bottom