Full Version: remove autosave
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
lostgirl12
hello,

i wanted my form to prompt the user if he wants to save the data he input if there is any when he wants to close the form...any ideas how i can go around doing this?
Jack Cowley
You can use code similar to this in a command button that will close the form. Be sure and remove the X in the upper right of the form so that user has to use your command button to close the form:

CODE
If Me.NewRecord Then

    Select Case MsgBox("Do you want to save this record?", vbYesNo Or vbExclamation Or vbDefaultButton1, Application.Name)

        Case vbYes

            'do nothing

        Case vbNo

            Me.Undo

    End Select

End If



DoCmd.Close


There are a lot of ways to skin this particular Access cat and this is just one of them...

hth,
Jack
lostgirl12
thanxs jack...
Jack Cowley
You are welcome...

Jack
jaspalkaler
Hi,

I figure there is no use saving a new record if it isn't dirty. So in Jack's solution may be you can substitute "If Me.NewRecord Then" line with "If Me.Dirty Then".

Jaspal Singh.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.