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.
Amine400Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
<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/
1
PatHartmanCommented:
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
Me.Refresh
"your export code"
Me.txtElapsedTime = DateDiff("ss", Me.txtStartTime, Now())
Me.txtFileName = "whatever second file name id"
Me.txtFileNum =  FileNum + 1
Me.Refresh
"your export code"
....

Me.txtEndTime = Now()
0
Amine400Author Commented:
The elapsed time should increment every second
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

John TsioumprisSoftware & Systems EngineerCommented:
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
sw.StartTimer

Open in new window

0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
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())
   Me.Refresh
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.  :)
0
Amine400Author Commented:
And what is the code ?
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
Get the elapsing seconds display working, and I'll work on the conversion code (which is a separate function).
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
Function that converts the number of seconds into a string formatted HH:MM:SS:

Public Function TimeString(lngSeconds As Long) As String
'Paul Cook-Giles 3/17/2017
Dim lngHours As Long, lngMinutes As Long
   lngHours = Int(lngSeconds / 3600)
   lngMinutes = (Int(lngSeconds / 60)) - (lngHours * 60)
   lngSeconds = Int(lngSeconds Mod 60)

If lngSeconds = 60 Then
    lngMinutes = lngMinutes + 1
    lngSeconds = 0
End If

If lngMinutes = 60 Then
    lngMinutes = 0
    lngHours = lngHours + 1
End If

TimeString = Format(CStr(lngHours), "#####0") & ":" & _
  Format(CStr(lngMinutes), "00") & "." & _
  Format(CStr(lngSeconds), "00")

End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amine400Author Commented:
Thanks
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.