Showing Last Updated Date

dax1226

Registered User.
Local time
Yesterday, 23:12
Joined
Dec 21, 2007
Messages
16
I have a form where I am currently showing the last updated user with the following code:

Private Sub Form_Current()
Me.Updated = fOSUserName
End Sub

I would like to add another field Date_Updated that shows the day that the record was updated. So far me.txtDate_Updated = date() has given me all kinds of errors. Is there another recommendation for displaying this value?

Also, unrelated, is there anyway I can suppress the first record in the dataset so that the last updated procedures are not constantly updating the very first record even when nothing has been changed?
 
Any code to show when a record has been updated, including your code above, needs to be in the Form_BeforeUpdate event, not in the Form_Current event! Code in the Form_Current event gets executed every time you move form record to record, whether the record has been changed or not.
 
Believe is stopped working last time I tried that, but I will check again. Thank you for that feedback.

Any idea on the actual date field?


Any code to show when a record has been updated, including your code above, needs to be in the Form_BeforeUpdate event, not in the Form_Current event! Code in the Form_Current event gets executed every time you move form record to record, whether the record has been changed or not.
 
There's really no ifs, ands or buts! The Form_Current will fire your code every time a record is visited, even if nothing is done except viewing the record! That's why the first record was always marked as "updated!" Your

me.txtDate_Updated = date()

should also work fine if placed in the Form_BeforeUpdate event. What kind of error(s) were you receiving?
 
The way I show update is directly in the table. Create a date/time field called last_update with the default set to Now(). Now every new record added will be timestamped. You can of course view this on your form if required. No code required, simple.

Chris B
 
Nextly (which isn't a word, but I like it) if you want to update the value when a record is changed, just add last_update = Now() to the after update event of the entry fields. Of course, the control needs to be on the form for this to work.

Chris B
 
Last edited:
And why in the world would want to do something in two places that only needs to be done in one?
 
Okay...got the before update item resolve.

In terms of the date_updated - I have been getting a Compile error stating "Method or data member not found"
 
I expressed it poorly. Which of the suggestions you might use would depend upon whether you wanted to capture just the creation date or any update. Ensure that no control / field is called Date.

Chris B
 
I expressed it poorly. Which of the suggestions you might use would depend upon whether you wanted to capture just the creation date or any update. Ensure that no control / field is called Date.

Chris B


Any update...

Currently I h ave the field setup on the form and hidden and the me.txtDate_updated=now() and that is what is causing the compile error.
 
Still receiving "Method or data member not found"

...Any help would be greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom