Updating "Date Modified" Field

G

Guest

Hello,

I have a field "Date Modified" in a table. Whenever someone adds a new
record to the table thru a form, the date its entered will be automatically
populated in the Date Modified field (default value as "Now()").

However, when someone changes the info to a record in the table thru a form,
the Date Modified field does not update the date the record was changed.

Can someone help me so that the field will update the date when one of the
fields in the record changes?

Thanks.
 
S

strive4peace

use for form BeforeUpdate event

me.DateModified_controlname = Now()


Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
 
G

Guest

Thanks strive4peace. Below is what I have per your instruction:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[Date Modified].Value = Now()
End Sub

Do I have it right? What is "controlname" in your code? The record is
changed in a sub form. I don't know that would matter.

Thanks again. Please help.
 
G

Guest

You can use On dirty property for the form

me!datemodified = now()

Amit K Garg
(e-mail address removed)
 
S

strive4peace

your code looks right

I use "controlname" because the NAME property of the control
is not always the same as the ControlSource... personally, I
make sure they are since the ControlSource is what shows up
in design view in the control and you have to use the
property sheet to see the name.

If the name is different, I change it for bound controls to
match the ControlSource -- this eases confusion ;)

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com

Thanks strive4peace. Below is what I have per your instruction:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[Date Modified].Value = Now()
End Sub

Do I have it right? What is "controlname" in your code? The record is
changed in a sub form. I don't know that would matter.

Thanks again. Please help.

:

use for form BeforeUpdate event

me.DateModified_controlname = Now()


Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
 
S

strive4peace

you're welcome ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
 
G

Guest

strive4peace,

Can you help me one more thing? If you would, please look for the tread
"Overwrite System Error Message". It is the tread the one after this one.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top