I ran into something really bizzaro today.
A team member had me look into some export code for some data he was
outputting. The data looks at shipping containers and attempts to look
at how often their being reused. Details are output according to the
maximum number of times the same container was used, up to a total of
six moves.
The code we're executing is so base-simple that it's second nature to
us. We have a select query that formats the data for output, and has a
static variable that corresponds to the maximum times the container was
used. Then, through code (see loop snippet at end of post), we loop
through the potential "max moves", and export the "format" query all
into the same workbook.
The bizzaro thing: As often as we've done this in the past (and our
users have similar routines running all day long), this is COMPLETELY
scrambling the data with each pass.
Pass 1: "Moves1" looks fine.
Pass 2: "Moves2" looks fine, but "Moves1" has some orders jumbled.
Pass 3: "Moves3" looks fine, "Moves2" has some orders jumbled,
"Moves1" is even more jumbled.
Pass 4: "Moves4" looks fine, "Moves3" has some orders jumbled,
"Moves2" is even more jumbled, and "Moves 1" is barely recognizable.
By the time pass 6 six hits, there are dozens of duplications in
Moves1. Data from completely different columns are moved around. The
original column headings are obliterated.
The code "ExportToXLS" basically runs DoCmd.TransferSpreadsheet, and
does some bolding, but does NO manipulation of actual data.
The only thing I can think of us the monstrosity of data in this
output. "Moves1" is 38K records, then 12K, 4K, 1K, 400, and "Moves6"
has 100 records.
Has anyone else encountered something like this? Insight appreciated.
Thanks,
Anthony.
For intX = 1 To 6
Call StaticInteger(intX)
strTempQuery = "Moves" & intX
' Delete the Temp Query (in case it didn't get deleted last time)
Call KillObject(strTempQuery, acQuery)
strSQL = "SELECT [BRT - qryTemp].* FROM [BRT - qryTemp];"
Set qdfBRT = dbBRT.CreateQueryDef(strTempQuery, strSQL)
Call ExportToXLS(strTempQuery, strOutputPath & strOutputFile)
'Cleanup - kill the Temp Query
Call KillObject(strTempQuery, acQuery)
Next intX