How to Get Date/Time on a Record

  • Thread starter Thread starter JAJansenJr
  • Start date Start date
J

JAJansenJr

This question may be answered elsewhere and, if so, I apologise. I'm totally
new to MS Access 2007. I want to automatically have a date/time appear in a
field which is entitled "Record Created" but only when the record is first
created. I also have a field entitled "Record Edited" in which I want the
date/time to be entered but only when the record is edited. I am able to use
the Now () function to get the current date/time to enter a field but I don't
know how to accomplish what I've stated in the foregoing. Any
ideas/suggestions/help will be greatly appreciated.
 
JA,

In design view of the table, you can set the Default Value property of
the Record Created field to Now() which should take care of the first
question.

The Record Edited field is not quite as easy. You will need to do this
in a macro that is assigned on the Before Update event or the After
Update event of the form that you use to edit the records.

There are a couple of approaches you could take. One would be to use a
SetValue action in the macro, to set the value of [Record Edited] to
Now(). Another would be to make an Update Query which updates the value
of the form's current record to Now(), and then use an OpenQuery action
in the macro to run the Update.
 
Back
Top