Automatic record saving

P

Pat Hartman

To stop the automatic save, you need to trap the save in
the correct event. You need to use the form's
BeforeUpdate event, NOT the close event as was suggested
by another poster. The close event runs AFTER the record
is saved so it is too late to prevent the save.

In the BeforeUpdate event, add code something like:
If msgbox("do you want to save?",vbyesno) = vbyes
Else
Cancel = True
msgbox "Update was cancelled",vbokonly
End If

The - cancel = True - cancels the update event so that the
record is not saved.
-----Original Message-----
I'm creating a Form in Access in which users have a
Component ID and they are allowed Associate existing
Actions to that Component. They enter some data, and then
when the Form closes (even if they click "X" or the Close
button, because they didn't want to Save the Action after
all), Access saves the record anyway. Is there any way to
turn off the Autosave and just allow the user to save the
record by clicking a Save button which will then save the
record through a Macro? Please shed some light on this
for me. Thanks!
 
J

jakeup

Hey Pat, I tried setting Cancel to True in the Before Update Event, but if it's called from the user clicking "X", then after Cancel is set to True and the form tries closing (having skipped the update), I get an error message saying that it is unable to save the record now and asking if i still want to close the form. Do you know how I can prevent that message from popping up without turning off the SetWarnings? Thanks!

Jake
 
R

Rocky B

Why not just deactivate the X button? That would save all problems.
All you have to do is double click the button next to the rulers and under
format tab find CloseButton. Change the default to no. Just ensure if you do
this you have a button to close the form.
 
L

luscioussarita

Thank you for answering this question!

Pat Hartman said:
To stop the automatic save, you need to trap the save in
the correct event. You need to use the form's
BeforeUpdate event, NOT the close event as was suggested
by another poster. The close event runs AFTER the record
is saved so it is too late to prevent the save.

In the BeforeUpdate event, add code something like:
If msgbox("do you want to save?",vbyesno) = vbyes
Else
Cancel = True
msgbox "Update was cancelled",vbokonly
End If

The - cancel = True - cancels the update event so that the
record is not saved.
Component ID and they are allowed Associate existing
Actions to that Component. They enter some data, and then
when the Form closes (even if they click "X" or the Close
button, because they didn't want to Save the Action after
all), Access saves the record anyway. Is there any way to
turn off the Autosave and just allow the user to save the
record by clicking a Save button which will then save the
record through a Macro? Please shed some light on this
for me. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top