Update the Last Modified Date

naungsai

Abecedarian
Local time
Tomorrow, 02:09
Joined
Sep 8, 2008
Messages
123
I have a date field named "ModifiedDate".
After I edit or change the value in the record, I want to change the last modified date in "ModifiedDate".

How should I do it?:D
 
In the Form's Before Update event, you set the modified date to

Me!ModifiedDate = Date
 
I have always used Dirty to check for the changes. In my view the code for Form's update event should go like this

If Me.Dirty Then
Me.ModifiedDate = Date
End If
 
I have always used Dirty to check for the changes. In my view the code for Form's update event should go like this

If Me.Dirty Then
Me.ModifiedDate = Date
End If

Just an FYI - If it is in the form's before update event, then the form is dirty if the before update event fires. It doesn't fire if nothing has changed. So, If Me.Dirty would be redundant in this case.
 
In the Form's Before Update event, you set the modified date to

Me!ModifiedDate = Date

i've tried to get this to work in my db's for some time. i keep getting the following error:

Update or CancelUpdate without AddNew or Edit
i first thought i must have been b/c i had my controls not in the 'detail' section of the forms, but even when i have these in the 'detail' section, i get that error. in a previous database, i remember this worked for a brief time, and only in some forms, but others would always return that error. i could never figure out what the difference was between the forms...

i know this is a simple thing to do in a db, and many people use it, so i'm a bit perplexed that i've never managed to get it to work
 
You cannot assign a value to a control on the form in the BeforeUpdate event.
 
You cannot assign a value to a control on the form in the BeforeUpdate event.

that would explain my problem - so how do you do it?

everyone here seems to be able to use the code Boblarson suggests (despite it being impossible) if not that, then what? and how come it works for everyone else??
 
To be honest I have never tried it because I read somewhere once that it could not be done. The same poster said to use the AfterUpDate event instead so that is what I do.

The main use of BeforeUpdate is running code to test the validity of a new value. I assume it does not allow values to be changed because one would not want another control changed if the update was rejected.

Edit:
Having now read the rest of the thread I'm curious. Would not be the first myth I have subscribed to after reading it somewhere.;)
 
Last edited:
Okay, try this -

instead of Me!ModifiedDate

use Me.ModifiedDate

with a period.
 

Users who are viewing this thread

Back
Top Bottom