Avatar of Amine400
 asked on

Microsoft access time counters

I am using a button in a form to extract 7 reports to 7 pdf files.
I wanna add some counters to my form :
-start time (button click)
-Elapsed time ( a chronometer format 00:00:00:00 hh:mm:ss:00) should refrech every millisecond )
-end time( all pdf files created with success )
if possible , i don't want a sample for download, i want a detailed code by steps.
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon
Rey Obrero (Capricorn1)

<i don't want a sample for download, i want a detailed code by steps. >
why not post in gig  https://www.experts-exchange.com/gigs/

I would not use a timer to refresh the form.  I would simply update the form after each export. Create the necessary form with fields named as below.

Dim FileNum as Int
FileNum = 0
Me.txtStartTime = Now()
Me.txtFileName = "whatever the first filename is"
Me.txtFileNum =  FileNum + 1
"your export code"
Me.txtElapsedTime = DateDiff("ss", Me.txtStartTime, Now())
Me.txtFileName = "whatever second file name id"
Me.txtFileNum =  FileNum + 1
"your export code"

Me.txtEndTime = Now()

The elapsed time should increment every second
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
John Tsioumpris

Use the on timer event..with interval 1000 --> 1000ms --> 1s
or use the stopwatch class
You create a class module and you paste the following code

Private mlngStart As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long

Public Sub StartTimer()
    mlngStart = GetTickCount
End Sub

Public Function EndTimer() As Long
    EndTimer = (GetTickCount - mlngStart)
End Function

Open in new window

The code is used like this
Dim sw as StopWatch
Set sw = New StopWatch

Open in new window

Paul Cook-Giles

1.  Dim a public variable in the form's module:  Public dtStartTime As Date
2.  Drop an unbound text field on the form, named txtTimeDisplay
3.  In your button that generates the PDFs, put    
dtStartTime = Now()

Open in new window

before the output commands  
4.  In the Form_Timer event, put
If dtStartTime > #12:00:00 AM# Then   
   Me.txtTimeDisplay = DateDiff("s", dtStartTime, Now())
End If

Open in new window

5.  In your button that generates the PDFs, put
dtStartTime = #12:00:00 AM#

Open in new window

This will give you an updating display of the number of seconds passing between the two variable population lines.

I can provide code that converts the number of seconds to HH:MM:SS, and/or populates another display field with the elapsed time.  :)

And what is the code ?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Paul Cook-Giles

Get the elapsing seconds display working, and I'll work on the conversion code (which is a separate function).
Paul Cook-Giles

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question