Modified Records

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

I'm trying to figure out how I can automatically populate
a date (modified) field when a record has been updated.

I have a form/table that has a Modified_Date field. I
also have the following VB script (Before Update):

Private Sub Form_BeforeUpdate(Cancel As Integer)
If vbNo = MsgBox("Are you sure you want to make these
changes?", _
vbQuestion + vbYesNo + vbDefaultButton2, "Confirm
Changes") Then
Cancel = True
Me.Undo
End If
End Sub

So the end result that I am looking for is that if the
record is saved after update, to automatically change the
Modified_Date field with Date().

I thank you in advance.

Frank
 
Private Sub Form_BeforeUpdate(Cancel As Integer
If vbNo = MsgBox("Are you sure you want to make these
changes?",
vbQuestion + vbYesNo + vbDefaultButton2, "Confirm
Changes") The
Cancel = Tru
Me.Und
Els
Me.Modified_Date = Dat
End I
End Su
 
Frank said:
I'm trying to figure out how I can automatically populate
a date (modified) field when a record has been updated.

I have a form/table that has a Modified_Date field. I
also have the following VB script (Before Update):

Private Sub Form_BeforeUpdate(Cancel As Integer)
If vbNo = MsgBox("Are you sure you want to make these
changes?", _
vbQuestion + vbYesNo + vbDefaultButton2, "Confirm
Changes") Then
Cancel = True
Me.Undo
End If
End Sub

So the end result that I am looking for is that if the
record is saved after update, to automatically change the
Modified_Date field with Date().

I thank you in advance.

Frank

Private Sub Form_BeforeUpdate(Cancel As Integer)
If vbNo = MsgBox("Are you sure you want to make these
changes?", _
vbQuestion + vbYesNo + vbDefaultButton2, "Confirm _
Changes") Then
Cancel = True
Me.Undo
exit sub
else
Me!Modified_Date=Now or Date or whatever format you require.
End If
End Sub

You can hide the date control on the form so the user will not see it or
be confused by it.

Do not do this in the AfterUpdate event. You can create a endless loop
updateing a bound control
in an AfterUpdate event at the Form Level. You have a never ending
update for the current record.

Ron
 
Back
Top