create a 'SAVE' button that will commit changes & avoid the 'before update' event?

RSIboy

Registered User.
Local time
Today, 17:02
Joined
Jul 1, 2004
Messages
32
create a 'SAVE' button that will commit changes & avoid the 'before update' event?

I appreciate Access by default commits changes on a form 'as they are made'. I have introduced some VBA, triggered by the 'before update' event which alerts the user that data on the form has changed, and asks whether to save or not.

However, this is a little cumbersome, as the user has to navigate to a different record/close the form etc. to trigger the event, to be able to save the record!

I would like to create a 'save' button that commits the changes on the form, but can't think how to avoid then triggering the 'before update' event. Perhaps I could use the save button click, to set a variable that will avoid the 'form has changed' prompt....

Any other ideas/suggestions much appreciated

Dale
Manchester, UK
 
Have you tried the "DoCmd.SetWarnings = FALSE" in VBA? Im not positive, but I think that would prevent the message youare talking about.
 
Workaround?

Create boolean variable right at the top of your form's module after the Option line(s):

Code:
Dim booUserClickedSave as Boolean

Then on the click even for your save button put code like this:

Code:
    booUserClickedSave = True
    DoCmd.RunCommand acCmdSaveRecord
    booUserClickedSave = False

Also, after any Dim statements at the top of the Form_BeforeUpdate event put code like this:

Code:
     If booUserClickedSave = True Then
        Exit Sub
    End If

I use this sort of code quite a bit, though I'm not sure if it's regarded as good practice. If it's not good practice someone will hopefully point out a better way.
 

Users who are viewing this thread

Back
Top Bottom