Record Changed Warning in Form?

  • Thread starter Thread starter xmp333
  • Start date Start date
X

xmp333

Hi,


I've got several forms that are bound to tables. One of the problems
is that a user can easily edit a form and move on to the next record
without realizing it -- Access doesn't warn the user that the record
was edited, or anything.

Is there a way to change this behavior? I'm ok with either having
Access warn the user up-front, or if the user tries to go to the next
record or perform any action that will commit the change.


Thanks in advance.
 
Check out Dirty property in Help...

Sub WarnUserOnEdits()
If Me.Dirty Then
' place msgbox/code/action here (Save record, Undo record, etc..)
End If
End Sub
--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH
 
Put code in the beforeUpdate event of the form:

(untested)

sub form_beforeupdate (cancel as integer)
cancel = ( inputbox ("ok to update?", vbyesno) = vbno )
end sub

HTH,
TC
 
Form_BeforeUpdate event is run whenever you insert or update current record
in your bound form (but not for record deletion) and you do some operation
that cause MS Access to save the current record. If you set Cancel argument
to True inside this event, MS Access will cancel record saving. (But data in
your form still in edit mode)

Example code is :

Private Sub Form_BeforeUpdate(Cancel As Integer)
if Msgbox("Would you like to insert/update record ?", vbQuestion +
vbYesNo + vbDefaultButton2) = vbNo then
Cancel = True
End If
End Sub

HTH
 
Put code in the beforeUpdate event of the form:
(untested)

sub form_beforeupdate (cancel as integer)
cancel = ( inputbox ("ok to update?", vbyesno) = vbno )
end sub

Unfortunately this event is triggered whenever the user navigates to
the next record or closes the form -- whether or not the data has been
changed. I need something that will detect if a change was made to
the form, or better yet, queries the user before allowing the form to
be edited.




Thanks.
 
Unfortunately this event is triggered whenever the user navigates to
the next record or closes the form -- whether or not the data has been
changed. I need something that will detect if a change was made to
the form, or better yet, queries the user before allowing the form to
be edited.

Then you must have code or a macro that is modifying every record that you
navigate to. BeforeUpdate is a very descriptive name. It does NOT fire
unless the record is updated.
 
Check out Dirty property in Help...
Sub WarnUserOnEdits()
If Me.Dirty Then
' place msgbox/code/action here (Save record, Undo record, etc..)
End If
End Sub

Tried it, no dice. I tried using this in the BeforeUpdate event, and
it was always marked as Dirty, even if the data didn't change. I then
trapped the OnDirty event and it never got triggered, even if the data
was changed.


--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH


Thanks.
 
Tried it, no dice. I tried using this in the BeforeUpdate event, and
it was always marked as Dirty, even if the data didn't change. I then
trapped the OnDirty event and it never got triggered, even if the data
was changed.

Since BeforeUpdate only fires when the record has been changed then
naturally the Dirty property is always true if tested in that event.

See S.L.'s reply. You can prompt in the BeforeUpdate event (without a
Dirty test) and cancel the event and issue an Undo if they indicate "No".
 
Back
Top