Date of Change

  • Thread starter Thread starter Stig
  • Start date Start date
S

Stig

Hi
I m still trying to add a field that shows when a record was updated.
I've tried putting Now() in the before update event but i cant get it to
work.
Am I missing something that's obvious?
Thanks for the help
Dave
 
Hi
I m still trying to add a field that shows when a record was updated.
I've tried putting Now() in the before update event but i cant get it to
work.
Am I missing something that's obvious?
Thanks for the help
Dave

You can't just set the BeforeUpdtae event property to Now() - Access
will have no clue what you are trying to do!

Instead, you will need to put a Date/Time field in your Table, let's
call it DateTimeChanged. Open the Form in design view; view its
Properties; and in the Form's BeforeUpdate event put code like

Private Sub Form_BeforeUpdate(Cancel as Integer)
<put any form validation code here>
Me!DateTimeChanged = Now
End Sub


John W. Vinson[MVP]
 
Stig said:
Hi
I m still trying to add a field that shows when a record was updated.
I've tried putting Now() in the before update event but i cant get it to
work.
Am I missing something that's obvious?
Thanks for the help
Dave

Make sure that there is a control on the Form for RevisedOn.

In the actual BeforeUpdate field on the Properties Sheet, type "[Event
Procedure]". This causes Access to look for a VBA procedure named
Form_<insert event name> (see below).

Right-click the form itself in Design View, select Build Event, and in the
Choose Builder dialog box, pick Code Builder (or click on the "Code" button
on the toolbar).

When VBA comes up, it'll have a default event procedure, Load, already
there. Delete it. Then paste the following in:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.RevisedOn = Now()

End Sub
 
Chris2 said:
Stig said:
Hi
I m still trying to add a field that shows when a record was updated.
I've tried putting Now() in the before update event but i cant get it to
work.
Am I missing something that's obvious?
Thanks for the help
Dave

Make sure that there is a control on the Form for RevisedOn.

In the actual BeforeUpdate field on the Properties Sheet, type "[Event
Procedure]". This causes Access to look for a VBA procedure named
Form_<insert event name> (see below).

Right-click the form itself in Design View, select Build Event, and in the
Choose Builder dialog box, pick Code Builder (or click on the "Code" button
on the toolbar).

When VBA comes up, it'll have a default event procedure, Load, already
there. Delete it. Then paste the following in:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me.RevisedOn = Now()

End Sub


There is a very simple solution to your issue.
Create a field (DateUpdated) in the underlying table as a date/time field
and set its default value to Date() or Now(). Then add the field to your
query, form, or report as necessary.
 
Brenda@DMS said:
[SNIP]

There is a very simple solution to your issue.
Create a field (DateUpdated) in the underlying table as a date/time
field and set its default value to Date() or Now(). Then add the
field to your query, form, or report as necessary.

That will give you an automatic "CreatedOn" field, but not an automatic
"ChangedOn" field which is what the OP asked for.
 
Back
Top