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

  • Follow


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


0
Reply duncanjx 12/3/2007 11:57:39 AM

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.

"duncanjx@optusnet.com.au" wrote:

> 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
1
Reply Utf 12/3/2007 2:28:01 PM


On Dec 4, 12:28 am, Jerry Whittle
<JerryWhit...@discussions.microsoft.com> wrote:
> 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.
>
>
>
> "dunca...@optusnet.com.au" wrote:
> > 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.....
0
Reply duncanjx 12/3/2007 9:18:35 PM

2 Replies
1182 Views

(page loaded in 0.089 seconds)

Similiar Articles:
















7/17/2012 8:45:44 AM


Reply: