Displaying elapsed time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use the followign command to import a file into my Access database:

DoCmd.TransferText acImportDelim, "Test Data Specification", "Test_Data",
Location, False

The file I'm importing is very large and can take up to 10 minutes to
import.

I would like to show the elapsed time (and continually update it) on the
Status Bar with a command like:

SysCmd acSysCmdSetStatus, "Elapsed Time: " & vTime

I was going to calculate the elapsed time with a formula that had a begin
time and end time but I'm not sure how to write the loop between the import
command and the next command (whatever it might be).

Any suggestions would be appreciated. Thanks for the help........
 
JT said:
I use the followign command to import a file into my Access database:

DoCmd.TransferText acImportDelim, "Test Data Specification", "Test_Data",
Location, False

The file I'm importing is very large and can take up to 10 minutes to
import.

I would like to show the elapsed time (and continually update it) on the
Status Bar with a command like:

SysCmd acSysCmdSetStatus, "Elapsed Time: " & vTime

I was going to calculate the elapsed time with a formula that had a begin
time and end time but I'm not sure how to write the loop between the import
command and the next command (whatever it might be).


You can easily get the current time using the Now function.

However, the difference between two times is a duration, not
a point in time so you can't just display the difference
without doing something to format it.

Here's some sample code to get you started:

Dim dtStart As Date
Dim dtEnd As Date
Dim lngMin As Long

dtStart = Now()
DoCmd.TransferText . . .
dtEnd = Now()
lngMin = lngMin + DateDiff("n", dtStart, dtEnd)
SysCmd acSysCmdSetStatus, "Elapsed Time: " & _
lngMin \ 60 & Format(lngMin Mod 60, "\:00")

Now that you know how to do the calculations, I have to
explain that you can not use this as a progress meter
because you can not interject a code sequence into the
middle of a synchronous operation such as TransferText.
AFAIK, all you can get is the total time for the operation.
For some operations, such as running a long query, Access
will display it's own progress meter, but I don't know how
it decides whether to do that or not.
 
Back
Top