Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2004
    Posts
    3

    Unanswered: Using a Timer (with Start, Pause, and Stop) to account for Session Length

    I am building a contact management database for a call center. Everything is pretty straightfoward...except for the timer. I don't know how to do this or where to begin.

    Essentially, I don't want the users to manually enter a time. I would like them to start a timer, be able to pause, and then stop the timer (after stopping, the elapsed time should enter in a field).

    Any ideas?

    I did this once with Filemaker -- but I did not consider a pausing feature. Start Button logged ComputerTimeA and StopButton logged ComputerTimePostA. The difference was automatically entered into a field Elapsed Time. However, I did not have a pause feature---which is making this a little complicated for me.

    Any help will be greatly appreciated.

    S

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Setup a 1 sec timer on your form ... When you click the Start log the date/timestamp. When you pause/stop do the same. Where are you going to hold these time pairings? Also, what are you gonna do with the time between pauses? Does it count?
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Instead of 'pause' time, I would consider them all start and stop. I would put them all into one table that assumes multiple records for a session. Associate each start and stop with the session, then when you calculate the 'Total', calculate each start and stop and then sum to get the total for the session.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I have a function for "pausing" for a specified time period, I will try dig it out for you.
    It's not pretty, but it works.
    George
    Home | Blog

  5. #5
    Join Date
    Jul 2004
    Posts
    3
    DCKunkle -

    I hadn't thought about that approach. Seems doable. I'll play around a bit.

    Essentially, the session can't close by pressing stop. I have to think of an alternative button, maybe Done.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Option Compare Database
    Option Explicit
    
    Public Function Pause(NumberOfSeconds As Variant)
    
    On Error GoTo Err_Pause
        
        Dim PauseTime As Variant, Start As Variant
        
        PauseTime = NumberOfSeconds
        Start = Timer
        
        Do While Timer < Start + PauseTime
            DoEvents
        Loop
        'MsgBox Timer - Start
    Exit_Pause:
        Exit Function
        
    Err_Pause:
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_Pause
        
    End Function
    Create a new module then use "Call Pause(<NumberOfSeconds>). The Do Events line means that it continues processing other code whilst the loop is running. Uncomment the messagebox line after to prove that it does pause.
    George
    Home | Blog

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    unless you need a pause functionality then why use it

    I'd take a timestamp [=now()]when the event starts, and another timestamp when the event ends, subtract the 2 give the event duration

    that way round you are not incurring the cost of the timer, also you cannot necessarily rely on the accuracy of the windows timer event, unless you set the granularity of the timer to at least twice the required accuracy., a call to now gives the immediate system date. The potential pitfall of this route is is say the system time changed whilst the process is happening... if that is conceivable then you will have to go down a timer route

    if you need a pause then you can extend the the function

    you may need say 2 (or preferably one) button(s) to take your timestamp values
    each activation of the button toggles the time process

    eg
    Private Sub cmdToggleTimer_Click()
    If cmdToggleTimer.Caption = "&Stop Timer" Then
    tbEventEnd = Now()
    tbEventDuration = DateDiff("s", tbEventStart, tbEventEnd)
    cmdToggleTimer.Caption = "&Start Timer"
    'you could any required business logic to say round up to the nearest minute/hour etc.
    Else
    tbEventStart = Now()
    cmdToggleTimer.Caption = "&Stop Timer"
    End If
    End Sub


    ..this assumes that you have 3 text boxes called tbEventStart, tbEventEnd & tbEventDuration, a command button called cmdToggleTimer, whoose caption on load is set to '&Start Timer'.

    you could extend this so that if you are looking at an old record the button is disabled.. place some code in the forms 'Current' event
    eg
    Private Sub Form_Current()
    If isnull(tbEventStart) then
    cmdToggleTimer.enabled=vbtrue
    else
    cmdToggleTimer.enabled=vbfalse
    End If
    End Sub

    HTH
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •