Timestamping changed records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm trying to populate a read-only field on a form with the time and date
the record was last changed.
This is to acheive seeing a list of records that have been updated this week
for example.
I have this at the moment:-

Private Sub Form_BeforeUpdate()
Last_Updated.Value = Now()
End Sub

When I've updated a record it won't save and when I try to move onto the
next record it does nothing, the button clicks but no response.
Does anybody have any idea where I'm going wrong or have any suggestions?

Would appreciate any help.
Thanks,
Lau
 
Is it possible that the code has become disassociated with the form?

Look at the properties associated with the form. Make sure it has [Event
Procedure] as the property for the form's BeforeUpdate event.
 
Laura83 said:
Hi,
I'm trying to populate a read-only field on a form with the time and date
the record was last changed.
This is to acheive seeing a list of records that have been updated this
week
for example.
I have this at the moment:-

Private Sub Form_BeforeUpdate()
Last_Updated.Value = Now()
End Sub

When I've updated a record it won't save and when I try to move onto the
next record it does nothing, the button clicks but no response.
Does anybody have any idea where I'm going wrong or have any suggestions?

Would appreciate any help.
Thanks,
Lau

Why do you describe your field as "read-only"? If your form and/or its code
is somehow set to not allow edits then you'd need to address that. What is
"Last_Updated", a text box? If so then try adding the "Me" keyword. The
following (from one of my apps) works in the Before Update event:

Me.txtUpdated = Now()

where txtUpdated is the name of my text box.

Regards,
Keith.
www.keithwilby.com
 
Is the form bound to a table? Does this table have a field named
Last_Updated?

In the code window, choose Tools | Options
On the General tab, set Error Trapping to:
Break on Unhandled Errors
You might now get the error message telling you what is wrong, i.e. why it
is not saving.
 
By Read-Only, do you mean Locked?

Can you update a Locked field?

Maybe you need to:

Me.field.locked = false
Me.field= Now()
Me.field.locked = true
 
My "Locked" theory was based in something other than reality. Sorry for the
misinformation. Locked just prevents users from typing in it, not code from
updating it.
 
Back
Top