Date of Change

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
 
J

John Vinson

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]
 
C

Chris2

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
 
B

Brenda@DMS

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

Rick Brandt

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.
 

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