Stamp Date Modified After Record in Form is Modified

zach9208

Board Regular
Joined
Dec 15, 2015
Messages
117
I am using Access 2013 and have tried everything to get this to work. I just want a record to be stamped with a modified date after any part of the record is changed. I cannot figure out why this isn't working.

I created a new field called Modified On with Date/Time format in table1. I then created a form based on table1. I then used the property sheet to set both an Event Procedure/Macro to the Before Update and neither worked.

Any ideas or is there something I am missing. Is this a bug in Access 2013?


https://support.office.com/en-us/ar...modified-0c46efc5-5b43-4751-b3a8-c246505af66d
https://www.techrepublic.com/blog/m...-the-date-and-time-of-the-last-record-update/
 
Removing a field from the form will probably have no effect one way or the other.
What is your current code you are using?
 
Last edited:
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
It works for me the way it is suggested in this link:
Let Access keep track of the date and time of the last record update - TechRepublic

my code:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.MOD_DT.Value = Now
End Sub

I would not do that the way you have it now. You simply create a FORM before update event to set the date modified in that field. That field doesn't need to be visible on the form, or even on the form at all, as long as it's in the table and the form is bound to the table.

Note that in Post #9 where you say the tech republic method did not work - you are *still* not doing it the way recommended in that post. You have a picture of a control before update event, for the MOD_DT control. You need to create a FORM before update event.
 
Last edited:
Upvote 0
Thanks so much xenou! Your code worked! Appreciate your patience!

I know I did not mention this in the earlier post, but is there a way to also record the current user who last modified a record.

It works for me the way it is suggested in this link:
Let Access keep track of the date and time of the last record update - TechRepublic

my code:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.MOD_DT.Value = Now
End Sub

I would not do that the way you have it now. You simply create a FORM before update event to set the date modified in that field. That field doesn't need to be visible on the form, or even on the form at all, as long as it's in the table and the form is bound to the table.

Note that in Post #9 where you say the tech republic method did not work - you are *still* not doing it the way recommended in that post. You have a picture of a control before update event, for the MOD_DT control. You need to create a FORM before update event.
 
Upvote 0
You do the same thing using this code:
Code:
environ("username")

for example, if you have a field called MOD_USER:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.MOD_DT.Value = Now
    Me.MOD_USER.Value = environ("username")
End Sub
That gives you the login name of the current user.
 
Upvote 0
Worked. Thanks again!
You do the same thing using this code:
Code:
environ("username")

for example, if you have a field called MOD_USER:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.MOD_DT.Value = Now
    Me.MOD_USER.Value = environ("username")
End Sub
That gives you the login name of the current user.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top