Thanks, Albert,
Am I right that this implies that on the moment I leave a record in a form
(by mouseclick or cursor), the changes in that record are committed? Is
there
a function to test for changes?
Yes, you can check the Dirty property.
if me.Dirty = True then
' changes have been made...
else
' changes have not been made
end if
You can also use the dirty proeryt to force a disk write...
if me.Dirty = True then
me.Dirty = false ' force data to disk
end if
So, to prompt the user to write data to disk, you could put the following
code in the before update event..
If Me.Dirty = True Then
If MsgBox("save data?", vbQuestion + vbYesNo, "Save") <> vbYes Then
Me.Undo
End If
End If
The above means if you navigate to another record, and don't change
anything, then the user would not be prompted to save. If you edit
something, and then try to move to anther record, the before update event
fires. We simply execute a me.undo to discard the changes...
Note that the before update event also has a cancel event, but that would
also stop the record navigation from occurring, and keep the user on the
current record if we set cancel = true.
By the way, since the before update event DOES NOT fire unless the record is
edited, then we actually don't need the dirty test...
The following code would suffice....
If MsgBox("save data?", vbQuestion + vbYesNo, "Save") <> vbYes Then
Me.Undo
End If