Access 2003; Create form Yes/No option for saving changes.

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

Guest

I am having trouble figuring out how to do the following. When someone opens
one of the forms in my database and makes a change, when they exit I want a
splash box with a Save Changes Yes or No button for selecting.

As it is now, it always saves everything. I set warnings to 'on', but they
do not make a difference.
 
Use the BeforeUpate event of the *form* to ask the user whether to save the
changes.

The event procedure uses MsgBox to ask the question:
Private Sub Form_BeforeUpdate(cancel As Integer)
If MsgBox("Save?" vbYesNo, "Confirm") = vbNo Then
Cancel =True
Me.Undo
End If
End Sub

If you actually have a command button on the form to close it, you need to
add this line above the Close:
RunCommand acCmdSaveRecord

Access has a horrid bug where it just loses your entry if you don't do that.
More info:
Losing data when you close a form
at:
http://allenbrowne.com/bug-01.html
 
Back
Top