Date Time Stamp on 2 separate fields when updated

lmac

Board Regular
Joined
May 12, 2005
Messages
103
I'm trying to add a date time stamp to two separate fields on my form. One field is where user enters their Start Time and the other field is where user enters their End Time. I've added 2 text boxes, StartSystemDateTimeLogged and EndSystemDateTimeLogged that I want the system date & time entered automatically when the user enters their Start Time and End Time. I've searched the forum and tried to use every suggestion I found but I can't get this to work. I have all four fields from the form in the same table and the StartSystemDateTimeLogged & EndSystemDateTimeLogged fields are hidden on the form so the user cannot see them. Any suggestions on how to make this work?
 

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,432
Hi

If you go into the form design, right click the start time box (that the user inputs the time into), click Properties -> Event Tab -> After Update -> click the 3 dots to the right -> Code Builder -> then enter the following between the Private Sub... and End Sub lines :

Me.StartSystemDateTimeLogged = Format(Now(), "General Date")

This will insert the current date and time into the field 'StartSystemDateTimeLogged' - I have assumed the format for this field in the table is 'General Date'. Save and close the VBA editor.

Repeat for the other input box but remember to change the field name.

HTH, Andrew :)
 

lmac

Board Regular
Joined
May 12, 2005
Messages
103
I promise I did this before but it gave me an error msg like "StartSystemDateTimeLogged macro cannot be found". I'll try it again.
 

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,432
If you try this step by step the way I explained it, then it should work provided you use the correct field name. There shouldn't be any refernces to macros.
Andrew :)
 

lmac

Board Regular
Joined
May 12, 2005
Messages
103
Thanks so much andrew. I tried it again & the problem was I added the StartSystem... & EndSystem text boxes to the form instead of adding them from the field list and forgot to change the text box names from Text49 & Text50 to the field names. That's where the problem was. It's working fine now.
 

Forum statistics

Threads
1,078,097
Messages
5,338,216
Members
399,213
Latest member
Braincraft

Some videos you may like

This Week's Hot Topics

Top