Auto Save in Forms

T

Tanya Stone

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
 
G

Graham R Seach

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
 
T

Tanya

Thanks Graham didn't think of doing that :cool:

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
 
T

Tom

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
 
Top