Auto Save in Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I realise that there is no way of turning off the "auto save on close" in a
form in access, and that you can use beforeupdate to test if the user wants
to save but what if i had a bound form where i only wanted the user to save
using a button, is there any way at all to cancel or undo, without prompting
the user to save, on the closing of the form.

hmm hope you can understand what I'm saying
 
Tanya,

Add a module-level variable:
Private blnOK2Save As Boolean

In the Click event for the save button, add the following code:
blnOK2Save = True
RunCommand acCmdSaveRecord
blnOk2Save = False

Then in the form's BeforeInsert and BeforeUpdate events, add the following
code:
If (blnOK2Save = False) Then Me.Undo

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Thanks Graham didn't think of doing that 8-)

Graham R Seach said:
Tanya,

Add a module-level variable:
Private blnOK2Save As Boolean

In the Click event for the save button, add the following code:
blnOK2Save = True
RunCommand acCmdSaveRecord
blnOk2Save = False

Then in the form's BeforeInsert and BeforeUpdate events, add the following
code:
If (blnOK2Save = False) Then Me.Undo

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Graham,

I am facing a similar situation, my edit form has a save command button but
the changes made are saved regardless of whether or not I press it. I was
attempting to use your instructions to Tanya but am not sure of the module
part. I simply went to the module section and created a new module and cut
and pasted the code into it saving it as module1, is this your intent?

Thanks, Tom
 

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

Back
Top