Ernst Guckel said:
Ok.. here's a bit more info:
'Process Archives for old or missing data
For i = 0 To DateDiff("d", dStartDate, Now())
strSalesDate = Format(dStartDate + i, STRING_IMPORTDATE)
strPath = strStoreNumber & "_" & strSalesDate
Some good extra info, thanks. You don't mention how many files on average
your processing in this loop. As I said before the speed of your code is not
going significantly affect this import system. as I said before, if it's
several hundred files that you're doing, then perhaps we eliminate the copy
command, and simply use a rename command (this is called the "name" command
in access).
strFileSource = STR_ARCHIVEPATH & "\" & strPath & "\" & STR_SOURCESALES
strCaption = "Importing - " & Format(dStartDate + i, "dd-mmm-yy")
With Forms("frmImport")
.Controls("lblStatus").Caption = strCaption
.Repaint
End With
For t = 1 To 10
Next
I use this because the .Controls("lblStatus").Caption = strCaption didn't
repaint right. Sometimes it hung up and sometimes it just stopped
updating
the user... A little look seem to let Access catch up with itself.
Ok...the repaint should have worked. if you want, you can remove the
Repaint, and put in a
doEvents
command in place of the loop + the repaint
(however, once again these issues have no significance in terms of the
performance issues were trying to deal with here)
And the last question you had I believe was how much data was in each text
file...
There are 96 records of about 10 fields each. Each import is a days worth
of data. I cannot string them together because I get them a day at a
time..
Well, we could write some code to string them together to make one fast
import, and that could significantly alter performance. So I well understand
you get these files one at a time, but I'm suggesting the *possible* idea of
doing some preprocessing to increase the speed of the import by a
significant amount. If we're to take 100 files, and convert them into one
file, then we would only do one transfertext file command, and that would
increased the speed of our import by 100 times (less the time of the code to
run and convert the text files into one text file).
Oh... I have to copy the file becuase Access does not seem to want to
import
a CSV formatted file without the .CSV extention. The filename originally
is
Works020.cdf. I could skip a step if I could import the original file
rather
than the copy....
As I said, you could put a little timer code to see if it's the transfertext
or in fact the file copy that slowing down the overall speed here. As I
said, the speed of executing each command is around the 80 million per
second mark, therefore the only way we can speed up this code is to limit
the number of times we execute the file copy (waits for windows os), and the
transfertext command (which again waits for windows).
here's what I mean by trying to find out is that the file copy or transfer
text that slow:
dim fTime as double ' file copy time
dim iTime as double 'import trans time
dim t as double ' timer
t = timer
FileCopy strFileSource, strFileDest
t = timer - t
fTime = fTime + t
Do The same idea for the import text command you're using.
and, at the very end of your code simply go
debug.print "file copy time = " & fTime
debug.print "input time = " & iTime
That way you'll get an idea if it's the actual file copy time, or the
transfer text time that's running slow. If it's the file copy code, then we
modify our code to rename the files in place of copying them. If it's the
transfer text command, that we explore some ideas like disabling the
indexing, or perhaps concatenation several text files into one.
You could also start (set) anohter variable with the timer value at the very
beginning of the code, and then take the difference at the VERY end of the
code. That way we can subtract that value and find out how much time is
taking to execute your actual code in your application (as compared to the
file copy, and transfer text command). As I stated before you'll find it
VERY VERY small amount (my bets are in the 30 million instructions per
second range by the way). in other words if we limit the time taken by the
file copy command, and also that of the transfer text command, you'll find
the rest of the codes execution speed is completely insignificant in this
situation.