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

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
 
J

Jerry Whittle

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.
 
D

duncanjx

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.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top