Date of Edit

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

Hi:

On my query, I need to have a field that shows the date that a record was
updated, however, the date can not change until the record is changed. I was
thinking that I can use the Date() function for this but I'm not sure how to
make it update with changes.

A solution would be awesome.

Thanks in advance.
Claire
 
Hi:

On my query, I need to have a field that shows the date that a record was
updated, however, the date can not change until the record is changed. I was
thinking that I can use the Date() function for this but I'm not sure how to
make it update with changes.

A solution would be awesome.

Thanks in advance.
Claire

You will need to do all your updating using a Form to accomplish this:
table datasheets have no useful events. You might need to implement
security (or draconian punishments, or both) to prevent people from
going around the form and editing data in a table or query datasheet.

Put a date/time field (let's call it Timestamp) in the table and
include it in the Form's recordsource query.

In the Form's BeforeUpdate event put

Private Sub Form_BeforeUpdate(Cancel as Integer)
<any form validation code goes here>
<if the data passes...>
Me![Timestamp] = Date ' for the date only, use Now for date & time
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Sometimes I over think things and try to make my work way too
difficult.....:-(

Many, many thanks John! Works wonderfully!!

Thanks also for all of the code in 'Microsoft Access 2003 - Inside Out'.
That wee reference book has saved my bacon more than once!! ;-)

Claire


Hi:

On my query, I need to have a field that shows the date that a record was
updated, however, the date can not change until the record is changed. I was
thinking that I can use the Date() function for this but I'm not sure how to
make it update with changes.

A solution would be awesome.

Thanks in advance.
Claire

You will need to do all your updating using a Form to accomplish this:
table datasheets have no useful events. You might need to implement
security (or draconian punishments, or both) to prevent people from
going around the form and editing data in a table or query datasheet.

Put a date/time field (let's call it Timestamp) in the table and
include it in the Form's recordsource query.

In the Form's BeforeUpdate event put

Private Sub Form_BeforeUpdate(Cancel as Integer)
<any form validation code goes here>
<if the data passes...>
Me![Timestamp] = Date ' for the date only, use Now for date & time
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Thanks also for all of the code in 'Microsoft Access 2003 - Inside Out'.
That wee reference book has saved my bacon more than once!! ;-)

One of my favorite books too... my friend John Viescas was kind enough
to send me an autographed copy!


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top