Solved Time stamp at update and record exit. (1 Viewer)

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
I have a form that records time() when the record is started. I would like to have it also record the current time when the record is exited. I need to be able to identify how much time has elapsed from the start of the record to the exit of the record. Start Time =time() how do i get the database to auto update the End Time on exit of record?

Do i need to create code ? or is this do-able with an expression in one of the event options? so far i have been unsuccessful in getting the time to appear after the cursor exits the field and the new/next record begins.

Ex:
Start time: 13:00 data data data data data End time: 13:02
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:42
Joined
Oct 29, 2018
Messages
21,454
Unfortunately, there is no "record exit" event right now (it's been a long time request). Closest thing you can have is ask the user to click an "Exit" button.
 

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
Unfortunately, there is no "record exit" event right now (it's been a long time request). Closest thing you can have is ask the user to click an "Exit" button.
ok .. no record exit ...bummer ... is there a way i can get access to record the time when the user enters the end time field? On focus?

I am trying to get away from the user having to key the time ... if i can get the database to give me a stop time - i can then calculate the time between start and stop to come up with total time ....

Exit button will not work here. This form is for a repetitive action .. they must record a case number and a resolution ... so .. i am looking to find out the elapsed time on each iteration so i can then calculate the total time spent for the day on this particular task.
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 02:42
Joined
Jan 23, 2006
Messages
15,379
How exactly do you get the start time?
Could you use the difference between 2 start times (or start time and form close if this is the last record to be processed?
 

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
How exactly do you get the start time?
Could you use the difference between 2 start times (or start time and form close if this is the last record to be processed?
Currently Start Time = time() then there is data entry ..... End time
then they move to the next line and do it again, and again , and again etc.

If the start and end time are both the same... it will make calculation of total time harder since i won't have minutes/seconds per line to accumulate.

I need the end time so that i can tell if they stopped for 2 hours and came back to this particular project. Otherwise i could use the first start time and last start time for total time, but that won't account for "time away".

Is it possible to record start time +1 minute? and have that update the end time? I could come up with the average time it takes to create the record and add that to start time .... ?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:42
Joined
Oct 29, 2018
Messages
21,454
Hi. Can you post a screenshot of your form? How does the user "move on" to the next line?
 

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
Hi. Can you post a screenshot of your form? How does the user "move on" to the next line?
1612997556493.png

They move with TAB from field to field then at End Time TAB starts new line.


This is a great example ... did i spend from 12:33 to 14:52 ? 2 hours and 19 min OR did i spend 12:33 - 13:00 - 20 minutes then walk away and RESTART at 14:52?
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:42
Joined
Feb 28, 2001
Messages
27,140
The only thing you might consider is that if you started a new record, you HAD to have left the old record. BUT that is one of the events that causes the record to be updated. So IF you captured the moment before that implied update, you could capture the time of day - which of course is the NOW() function in the form's (or sub-form's, if applicable) FORM_BEFOREUPDATE event. If the user moves out of the form row where the record is being entered, that is an update. The problem, of course, is if they leave and come back, things might become a bit more complex.
 

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
The only thing you might consider is that if you started a new record, you HAD to have left the old record. BUT that is one of the events that causes the record to be updated. So IF you captured the moment before that implied update, you could capture the time of day - which of course is the NOW() function in the form's (or sub-form's, if applicable) FORM_BEFOREUPDATE event. If the user moves out of the form row where the record is being entered, that is an update. The problem, of course, is if they leave and come back, things might become a bit more complex.
i did try putting the expression =time() (Expression builder) in the event - onexit - ongotfocus - onenter - none of these actually put the time in the field...

am I missing some other trigger I need to do ? I am fairly new to Access. I know in general what "kinds of things" a data base can do .. but I am not very savvy on how to tell Access what it is I WANT to do !
 

Aryzona

Member
Local time
Yesterday, 23:42
Joined
Nov 14, 2020
Messages
49
I figured it out !

Once they enter the case number - they must go to a webpage and do the document processing - then they mark if it was "complete" , a "problem" or "UTL (Unable to Locate)" so I did the following event for each as only 1 will apply :

Private Sub UNcp_AfterUpdate()
Me.UNet = Time()
End Sub

UNcp is "complete" and UNet is "End Time"

as soon as I put the check mark in the "complete" field the "End Time" updated!

Thank you all for your suggestions and help - just kicking it sometimes is all we need :D
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:42
Joined
Feb 28, 2001
Messages
27,140
So true, @Aryzona - part of the problem for newer users of Access is to learn the names of the things we do with events, routines, etc. Some of it is common to the industry. Some of what we do comes from Access itself or from Office.
 

Users who are viewing this thread

Top Bottom