Ready for a really remedial question about tracking when a record was last updated?

  • Thread starter Thread starter Barbra Lehto
  • Start date Start date
B

Barbra Lehto

I seem to remember back in the olden days that Access automatically stored
the date when a record was created and when a record was updated. Is this
still true? If so, where do I find these dates and how do I use them in a
query?

If not, what's the best way to track these two dates?

Thanx

Barbra
 
Hi Barbara,

To the best of my knowledge Access never stored this information for you.
You have to do it yourself. Add the fields to each table you want them in
and then on the appropriate forms add code to the BeforeUpdate event to
update these new fields.

You can test the NewRecord field to make sure that you only update teh
DateEntered field just before the first update of a new record.
 
Ah, I was afraid of that. Thanx for your quick response.


Sandra Daigle said:
Hi Barbara,

To the best of my knowledge Access never stored this information for you.
You have to do it yourself. Add the fields to each table you want them in
and then on the appropriate forms add code to the BeforeUpdate event to
update these new fields.

You can test the NewRecord field to make sure that you only update teh
DateEntered field just before the first update of a new record.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Barbra said:
I seem to remember back in the olden days that Access automatically stored
the date when a record was created and when a record was updated. Is this
still true? If so, where do I find these dates and how do I use them in a
query?

If not, what's the best way to track these two dates?

Thanx

Barbra
 
Okay, color me clueless, but I just can't get this date thing to work. Can
anyone give me the specific code or expression I need to automatically
populate a "date added" field when the record is first created, and a "date
updated" field when the record has changed?

Thanx

Barbra


Barbra Lehto said:
Ah, I was afraid of that. Thanx for your quick response.


Sandra Daigle said:
Hi Barbara,

To the best of my knowledge Access never stored this information for you.
You have to do it yourself. Add the fields to each table you want them in
and then on the appropriate forms add code to the BeforeUpdate event to
update these new fields.

You can test the NewRecord field to make sure that you only update teh
DateEntered field just before the first update of a new record.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Barbra said:
I seem to remember back in the olden days that Access automatically stored
the date when a record was created and when a record was updated. Is this
still true? If so, where do I find these dates and how do I use them
in
 
Barbra Lehto said:
Okay, color me clueless, but I just can't get this date thing to work. Can
anyone give me the specific code or expression I need to automatically
populate a "date added" field when the record is first created, and a "date
updated" field when the record has changed?

For the DateAdded field just set the default value property to Date() at the
table level. For the DateUpdated field use the following in the BeforeUpdate
event of the form...

Me.DateUpdated = Date()
 
The date added thing worked great--can it be so simple!?

I have tried every which way on the date update one and it doesn't work. I
keep getting errors saying the system is looking for a macro. I've tried
expressions, code, and macros and still get an error.

I think the problem is that the form want to set a property not a value
after the update. When I tried using code, it wouldn't let me put in
Date(), it kept stripping the parens, making the statement nonsense.

Any other thoughts?
 
Barbra Lehto said:
The date added thing worked great--can it be so simple!?

I have tried every which way on the date update one and it doesn't work. I
keep getting errors saying the system is looking for a macro. I've tried
expressions, code, and macros and still get an error.

I think the problem is that the form want to set a property not a value
after the update. When I tried using code, it wouldn't let me put in
Date(), it kept stripping the parens, making the statement nonsense.

Any other thoughts?

Sounds like you entered the code...

Me.DateUpdated = Date()

....directly into the AfterUpdate property. That's not how event code
works. Anything entered directly into the event property has to be the
name of a function or the name of a macro. To run VBA code in that event
you enter...

[Event Procedure]

....into the event property and then press the build [...] button to the
right of the property. This will take you to the VBA code editor window.
Access will already have defined the event sub beginning and ending lines
for you and then you enter your code between those lines.
 
Back
Top