Access form start time and end time

psamu

Active Member
Joined
Jan 3, 2007
Messages
462
I would like to add start and end time in the access form. if the user open immediately need to start the time counter and when it saves the record end the time counter need to update for calculating the average time for updating a record. Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
There may be a simpler way, but here's one. Replace the control names with your own. I'm assuming the save event is triggered by a button. Each subsequent button click will increment the duration. If you want to start the clock again if user moves to a different record, then I have not accounted for that - you do not say what kind of form you have. Nor did you say if you want the result in seconds or minutes. If none of this works for you, you will at least now have a concept.
For your form open event:
Code:
Me.txtStart = Time
Me.txtEnd = ""

For your button click event:
Code:
Me.txtEnd = Time
Me.txtDuration = getDuration
Me.Refresh

In your form module:
Code:
Function getDuration() As Long
Dim lngStart As Variant, lngEnd As Variant
lngStart = Me.txtStart
lngEnd = Time
getDuration = DateDiff("s", lngStart, lngEnd) ' s for seconds
End Function

If you have issues, I will not be able to respond in a timely manner after today.
 
Last edited:
Upvote 0
Thanks . I have continuous form. Field name as StartTime and another field name as EndTime. There are few filed user has to update. If user open a particular record and time start when user start updating the first field and the time end when user click on move to next record .
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,877
Members
449,056
Latest member
ruhulaminappu

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