Creating Stopwatch in Access (1 Viewer)

omarrr128

Member
Local time
Today, 15:54
Joined
Feb 5, 2023
Messages
69
Hi ,

I really need some help as I'm struggling on this. I want to create a stopwatch timer that is on a form for each record.

The form displays a list of jobs which users add their name to. I know how to show the start time but I need a counter next to it in the format 00:00 that shows how long they are on job for from when they click a button.

Ive already searched a lot on google but i cant figure it out. Can anyone help tell me how? Or even create it for me?

Im not at all Good at coding.

Thanks
 

Attachments

  • SMH PORTER V4.accdb
    2.4 MB · Views: 71
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 15:54
Joined
Sep 21, 2011
Messages
14,322
I would expect it to just be start time subtracted from end time and formatted as you wish?, probably hh:mm ?

From a quick test in the immediate window
Code:
tt=now()
? Format(Now()-tt,"hh:mm:ss")

Wait a suitable interval and then press enter on the format line
00:03:24
I used hh:mm:ss format
 

ebs17

Well-known member
Local time
Today, 16:54
Joined
Feb 7, 2020
Messages
1,949
You can find a stopwatch class here:
 

omarrr128

Member
Local time
Today, 15:54
Joined
Feb 5, 2023
Messages
69
I would expect it to just be start time subtracted from end time and formatted as you wish?, probably hh:mm ?

From a quick test in the immediate window
Code:
tt=now()
? Format(Now()-tt,"hh:mm:ss")

Wait a suitable interval and then press enter on the format line
00:03:24
I used hh:mm:ss form
but im very cofused how to integrate this? how do i connect a text box and button to this code?
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:54
Joined
Sep 21, 2011
Messages
14,322
Well the button executes the calculation using Now()
So if the control is called Duration and the Start Time called StartTime, then ....
Code:
Me.Duration = StartTime - Now()
Make the format of the duration control hh:mm or possibly hh:mm:ss
If you want to store it, leave it as a datetime data.

Really depends on how accurate you want it? Would you want to round it to the nearest minute if just using hh:mm ?
 

isladogs

MVP / VIP
Local time
Today, 15:54
Joined
Jan 14, 2017
Messages
18,241
See also

Stopwatch class is included in the example database supplied with that article.
However there are many other equally good, if not better, methods of timing code also included in the article
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:54
Joined
May 7, 2009
Messages
19,248
see if this is what you need.
 

Attachments

  • SMH PORTER V4.accdb
    4.3 MB · Views: 100

omarrr128

Member
Local time
Today, 15:54
Joined
Feb 5, 2023
Messages
69
see if this is what you need.
is it possible to make it refresh every minute instead of second? I have tried changing the timer interval on the form properties and in the module but it doesnt seem to change. It will give users time to reconsider their actions like adding jobs or notes or finishing jobs. I dont need the seconds in the timer. If not possible thats okay. Thank you :)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:54
Joined
May 7, 2009
Messages
19,248
1 second for timer = 1000 ms.
multiply it by 60 (for 1 minute)

TimerInterval = 60000

you won' see the changes until 1 minute has passed.
 

omarrr128

Member
Local time
Today, 15:54
Joined
Feb 5, 2023
Messages
69
1 second for timer = 1000 ms.
multiply it by 60 (for 1 minute)

TimerInterval = 60000

you won' see the changes until 1 minute has passed.
thank you for all your help. This worked well but there was a me.requery somewhere else in the code that was confusing but all sorted now :)
 

Users who are viewing this thread

Top Bottom