Consulting

Results 1 to 6 of 6

Thread: Assistance With Building Timer to Track Test Runs

  1. #1

    Assistance With Building Timer to Track Test Runs

    Hello everyone. I am trying to build an Access Database to create records each time we run a test case(SimMode) and track how long it takes the SimMode to turn on(AgeIn) and turn off(AgeOut). The issue I am having right now is that I only need/want seconds/milliseconds to be displayed and I feel like I'm hitting a wall .

    So to break it down I have two questions.

    1) How can I get my data to store into Access as 00:00.00?

    2) How should I go about building this stopwatch/timer?


    Ideally I would thrilled if I could control the timer with one button. i.e. MouseClick down to start and MouseClick Up to stop.


    Side Note: I'm an absolute amateur but I am desperately trying to improve my skills. (see horrible code below)

    Any help would be greatly appreciated

    Private Sub Command51_MouseDown()

    Dim StartTime As Date
        Dim StopTime As Date
    
    
        StartTime = Now()
    
    
        Expression.MouseUp
    
    
        StopTime = Now()
    
    
        AGEIN = StopTime - StartTime
    
    
    
    
    End Sub
    Also tried this one with two buttons. It seems to work down to the second but I would also like the value to be stored as seconds/milliseconds in my database if possible

    Private Sub Command51_Click()
    
    
        AGEIN = Now()
        
    End Sub
    
    
    Private Sub Command52_Click()
    
    
        Dim StartTime As Date
        Dim NewTime As Date
        
        StartTime = AGEIN
        
        AGEIN = Now() - StartTime
        
    End Sub
    Last edited by chaserankin; 02-24-2022 at 08:06 PM.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Static StartTime As Date
    Function AgeIn() As String
    If StartIme = 0 Then 
        StartTime = Now
        AgeIn = ""
    Else
       AgeIn = Format(Now - StartTime, "mm:ss.####)
       StartTime = 0
    End If
    End Function
    If AgeIn = "" Then DO Nothing
    IF AgeIn = (A value) then that is the process time

    Sub StartProcess
        ProcessTime = AgeIn 'Starts Timer
        'Blah
        'Blah
        'Blah
    End Sub
    Sub Process End
        'Blah
        'Blah
        'Blah
        Process Time  = AgeIn 'This is the Time
    End Sub
    Sub ReSetAgeIn()
       StartTime = ""
    EndSub
    If you use the MicroTimer, Do the conversions to decimal seconds after reading the value from Access.
    Last edited by SamT; 02-26-2022 at 12:11 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    sample demo.
    Attached Files Attached Files

  5. #5
    Thanks everyone for the help. arnelgp I don't know how you built such a perfect implementation of what I was looking for based off of my weak description. Well done.

  6. #6

Posting Permissions

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