This is the situation. I have created a routine to count the number of detail records in a file (AMARTRS & AMARTRSH), place what record number it is (1,2,3, etc.) in the same files, and give a sum count in the header file(AMARREC & AMARRECH). The relationship between the two files is finvno.
When I hit the findfirst part of the routine, the program really bogs down and takes 20 minutes to run when there is 900 records in the master file. I am afraid to time how long it will take with live data that numbers in the tens of thousands.
Here is the code:
Set rstARREC = dbs.OpenRecordset("SELECT * FROM amARREC ORDER BY finvno"
Set rstARRECH = dbs.OpenRecordset("SELECT * FROM amARRECH ORDER BY finvno"
Set rstARTRS = dbs.OpenRecordset("SELECT * FROM amARTRS ORDER BY finvno"
Set rstARTRSH = dbs.OpenRecordset("SELECT * FROM amARTRSH ORDER BY finvno"
'****Begin adding record counts
lblMsg.Caption = "Matching the Header records with the Detail records"
rstARREC.MoveFirst
rstARTRSH.MoveFirst
Do While rstARREC.EOF <> True
intRecCounter = 0
'this is the line that really slows down the program
rstARTRSH.FindFirst ("finvno = '" + rstARREC!finvno + "'"
Do While rstARTRSH.EOF <> True
If rstARTRSH!finvno <> rstARREC!finvno Then
Exit Do
End If
intRecCounter = intRecCounter + 1
'updating artrs with the total number of lines
rstARTRSH.Edit
rstARTRSH!fnumlines = intRecCounter
rstARTRSH.Update
rstARTRSH.MoveNext
Loop
'updating arrec with the total number of lines
rstARREC.Edit
rstARREC!fnumlines = intRecCounter
rstARREC.Update
rstARREC.MoveNext
rstARTRSH.MoveFirst
Loop
Can anyone come up with any ideas on how to speed this up? I thought of creating a primary key on finvno in the detail file, but there are duplicate records, and no other records in the file are unique. My only other thought was to create a new auto-number field in the detail file, and populate it, thereby giving me my second unique field (finvno + autonumber). The only problem with this is would it speed it up enough to justify spending the extra time?
ANy question or suggestions, please reply.
Thanks for looking,
-Chuck
When I hit the findfirst part of the routine, the program really bogs down and takes 20 minutes to run when there is 900 records in the master file. I am afraid to time how long it will take with live data that numbers in the tens of thousands.
Here is the code:
Set rstARREC = dbs.OpenRecordset("SELECT * FROM amARREC ORDER BY finvno"
Set rstARRECH = dbs.OpenRecordset("SELECT * FROM amARRECH ORDER BY finvno"
Set rstARTRS = dbs.OpenRecordset("SELECT * FROM amARTRS ORDER BY finvno"
Set rstARTRSH = dbs.OpenRecordset("SELECT * FROM amARTRSH ORDER BY finvno"
'****Begin adding record counts
lblMsg.Caption = "Matching the Header records with the Detail records"
rstARREC.MoveFirst
rstARTRSH.MoveFirst
Do While rstARREC.EOF <> True
intRecCounter = 0
'this is the line that really slows down the program
rstARTRSH.FindFirst ("finvno = '" + rstARREC!finvno + "'"
Do While rstARTRSH.EOF <> True
If rstARTRSH!finvno <> rstARREC!finvno Then
Exit Do
End If
intRecCounter = intRecCounter + 1
'updating artrs with the total number of lines
rstARTRSH.Edit
rstARTRSH!fnumlines = intRecCounter
rstARTRSH.Update
rstARTRSH.MoveNext
Loop
'updating arrec with the total number of lines
rstARREC.Edit
rstARREC!fnumlines = intRecCounter
rstARREC.Update
rstARREC.MoveNext
rstARTRSH.MoveFirst
Loop
Can anyone come up with any ideas on how to speed this up? I thought of creating a primary key on finvno in the detail file, but there are duplicate records, and no other records in the file are unique. My only other thought was to create a new auto-number field in the detail file, and populate it, thereby giving me my second unique field (finvno + autonumber). The only problem with this is would it speed it up enough to justify spending the extra time?
ANy question or suggestions, please reply.
Thanks for looking,
-Chuck