Recording the date and time when a record is modified in Access

  • Thread starter Thread starter duncanjx
  • Start date Start date
D

duncanjx

Recording the date and time when a record is modified in Access
Create a macro named LastModified and set its action and item
arguments as described in the following table: Action
Item Expression
SetValue [DateModified] Date()
SetValue [TimeModified] Time()

Set the BeforeUpdate property of the form to LastModified (the name of
the macro).
...................................................................................................................
It does not work for me and I am trying to work out why not.

I have DataModified and TimeModified as fields on my form. I have set
the BeforeUpdate property on the form.

I get an error message, "The object doesn't contain the Automation
object 's' ".


Don't know why not?

Cheers
 
Two suggestions.

1. Don't use a macro. Instead use code like below in the BeforeUpdate event
which will do the same thing better.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Then
Me.DateModified = Now()
End If
End Sub

2. Store the date and time in just one field instead of two. You'll find it
much, much easier to compare dates and times that way. Now will insert both
the date and time into the DateModified field.
 
Two suggestions.

1. Don't use a macro. Instead use code like below in the BeforeUpdate event
which will do the same thing better.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Then
Me.DateModified = Now()
End If
End Sub

2. Store the date and time in just one field instead of two. You'll find it
much, much easier to compare dates and times that way. Now will insert both
the date and time into the DateModified field.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.



Recording the date and time when a record is modified in Access
Create a macro named LastModified and set its action and item
arguments as described in the following table: Action
Item Expression
SetValue [DateModified] Date()
SetValue [TimeModified] Time()
Set the BeforeUpdate property of the form to LastModified (the name of
the macro).
...........................................................................-........................................
It does not work for me and I am trying to work out why not.
I have DataModified and TimeModified as fields on my form. I have set
the BeforeUpdate property on the form.
I get an error message, "The object doesn't contain the Automation
object 's' ".
Don't know why not?
Cheers- Hide quoted text -

- Show quoted text -

______________________________________________________________________________________________
Thanks for the reply.
I did as suggested. I built the code but the DateModified Field does
not alter or change when I change other fields, save, move to next
record and come back???????????
Still not sure.....
 
Back
Top