How to create stopwatch in access and save result in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msamir12
    New Member
    • Dec 2015
    • 12

    #1

    How to create stopwatch in access and save result in a table

    Hi ..
    I need to create a stopwatch form in Microsoft access and when stopping the stopwatch I can save the result into a table so that I can later do calculations on this result .. can any one please help me doing this ?
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    That's not what Access, or really any database, was intended to do.

    You could use the form's on_timer event, set to 1000 which would trigger the event every second (the event is in milliseconds)
    Three buttons (maybe toggle the first two here?):
    one to set the timer event to 1000 (start)
    one to set the timer event to 0 and save your record (stop)
    one to reset the timer and display.

    Form level variable to hold elapsed times

    procedure to be executed every time the timer event triggers to store the loop count to the form level variable. This way each time the event triggers the variable is incremented by 1 second. I would simply store the elapsed time as seconds as one can calculate what you need from there....

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I agree with the overall design. However, I wouldn't use a loop counter in the timer to keep track of elapsed time. The timer event isn't guaranteed to fire at exactly 1000 ms after the last time it fired, it could take slightly longer. So over time it gets further and further out of sync with the actual elapsed time. Plus it takes cycles to run the code within the timer event itself. Instead, when the timer event is started, log the timestamp and use the timer event to calculate the current timestamp against the variable.
      Last edited by Rabbit; Dec 16 '15, 08:46 PM.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        I had thought about pulling the time stamp; however, I wasn't sure of the time lag - in principle, I agree with Rabbit's modification.

        The path to follow may depend on the degree of acceptable error in the time measurement.

        Comment

        Working...