We help IT Professionals succeed at work.

Microsoft access time counters

Amine400
Amine400 asked
on
124 Views
Last Modified: 2017-03-17
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.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

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/
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
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()

Author

Commented:
The elapsed time should increment every second
John TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
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

Paul Cook-GilesSenior Application Developer
CERTIFIED EXPERT

Commented:
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.  :)

Author

Commented:
And what is the code ?
Paul Cook-GilesSenior Application Developer
CERTIFIED EXPERT

Commented:
Get the elapsing seconds display working, and I'll work on the conversion code (which is a separate function).
Senior Application Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions