recording the last date that data is changed

  • Thread starter Thread starter Paul Ponzelli
  • Start date Start date
P

Paul Ponzelli

I would like to store the last date that a change is made to data in any
field in a record. However, I don't want this to occur when a user simply
opens a form and looks at the data; I only want this date to get set to the
current date if the user modifies data in any way.

Will the After Update event serve this purpose, and can I just write
"Me.txtLastModified = Date()"?

Thanks in advance,

Paul
 
Paul said:
I would like to store the last date that a change is made to data in
any field in a record. However, I don't want this to occur when a
user simply opens a form and looks at the data; I only want this date
to get set to the current date if the user modifies data in any way.

Will the After Update event serve this purpose, and can I just write
"Me.txtLastModified = Date()"?

Thanks in advance,

Paul

Use BeforeUpdate not AfterUpdate. If you update a record in the AfterUpdate
event you create a loop.
 
If I use the Before Update event, I think I need to confirm that the user
doesn't cancel the update.

Can I do that with

If Cancel <> true then
[run my code]
End If

??
 
Paul said:
If I use the Before Update event, I think I need to confirm that the
user doesn't cancel the update.

Can I do that with

If Cancel <> true then
[run my code]
End If

??

If they cancel the update then any changes made in the BeforeUpdate are also
cancelled.

Unless...are you talking about recording this date in a field of the record
being updated or in a separate table? If in the record being modified then use
BeforeUpdate and you will not have to worry about the user cancelling changes.
If you are storing it in another table then you DO need to use AfterUpdate, but
in that case you would need to run an update query or append query. A simple
Me!FieldName = Date() will only work if "FieldName" is a field in the same
record being changed.
 
Yes, it's a field in the same table with that of the record being changed.

Thanks, Rick.
 
I think you're correct, Rick. I always use the BeforeUpdate event. I wasn't
paying enough attention

However, I do seem to recall that MichKa had some reason for suggesting
using AfterUpdate.
 

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

Back
Top