Running Time Accumulations (1 Viewer)

andysgirl8800

Registered User.
Local time
Yesterday, 21:06
Joined
Mar 28, 2005
Messages
166
Progress:
I've inserted a stopwatch as a subform (frmTimer) on my main form (frmTicket). The subform has three buttons, Start/Stop, Save, and Reset and an unbound field (ElapsedTime) that displays the elapsed time. The Start/Stop and Reset buttons are self-explanitory. The Save button takes the displayed time (formatted as HH:MM:SS:MS) after Stop has been pressed and exports that value into a field (Time) on my main form. That's as far as I've gotten, and now I'm stumped.

Goal:
What I'm trying to set up is a way for a user to track how much time they spend researching a ticket. So each time they open a record, the stopwatch will start running to measure how long they have been working on it. Once they are done with that record for that day, they will hit the Stop button. Because this same record may be accessed any number of times before the ticket is resolved, I need to keep a running total of time that has been spent on this particular record.

Issues:
The stopwatch resets to zero once the record is closed, and is not independently dedicated to each record. The field (Time) on my main form into which I transfer the stopped time recording is bound to my table (tblTicket), but will be repopulated with a new time each time the Save button is clicked.

Question:
How can I store the first time stamp so that each new time stamp can be added to it for a running total? Thanks for any help you can provide!
 

Banana

split with a cherry atop.
Local time
Yesterday, 20:06
Joined
Sep 1, 2005
Messages
6,318
I understand that Timer function is well... crappy.

What I would do instead is create a temporary local table that is created when user opens the database, then whenever user clicks Start button, a new entry is made in the temp table with the timestamp of Start and the record number. The temp table will continue to store the timestamp for several records as needed. When the user is done and clicks the Stop, the new timestamp (using Now()) is recorded, subtracted from the Start timestamp and you now have the elapsed time for the ticket.

I'm not 100% sure what you mean by running total, but if it's in cumulative sense, then you can add the elapsed time with the last elapsed time stored in the ticket's record.
 

andysgirl8800

Registered User.
Local time
Yesterday, 21:06
Joined
Mar 28, 2005
Messages
166
That's exactly what I am trying to do, but would you please be able to provide more detail? How would this work? I've never used a temporary table before. Thanks for your help!
 

Banana

split with a cherry atop.
Local time
Yesterday, 20:06
Joined
Sep 1, 2005
Messages
6,318
By "temporary table", I meant a table that looks and acts like a regular table, but the data inside are always deleted manually.

I suppose the structure would be something like:

ID
UserName
RecordID 'FK to the ticket record
StartTime
StopTime

You would then use a standard module to manage all this from various locations. Here's a primer:

Code:
Private mrst as DAO.Recordset

Public Sub Init() 'This must be called first, preferably from the first form that opens in the database

Dim db As DAO.Database

Set db= CurrentDb()
Set mrst=db.OpenRecordset("YourStopWatchTableName")

End Sub

Public Function StartTime(User As String, RecordID as Long)

With mrst
   .AddNew
   .UserName=User
   .RecordID=RecordID
   .StartTime=Now()
   .Update
End With

End Function


Then you just call this whenever your user opens the ticket record:
Code:
StartTimer(UserName, RecordID)

If you do not understand any of those, read up on Access help for explanation on keywords, and use Google to see how they all work together, then you will be able to write the rest of code yourself.

HTH.
 

Users who are viewing this thread

Top Bottom