I have an application where I need to run a series of do loops with nested if then statements. The code looks like this:
sql statement to calculate rst2!variance
Do until rst1.eof
If rst1!AR = rst2!AR then
If rst1!COA = rst2!COA then
If rst1!Part_No = rst2!Part_No
rst1!Variance = rst2!Variance
rst2.movenext
rst1.movefirst
else
rst1.movenext
end if
else
rst1.movenext
end if
else
rst1.movenext
end if
loop
Unfortunately, I have about 30 of these loops in my code as I update a table with various calculated fields. The calc fields are not simple A*B, but more like sum of this group of records...count of records that meet this criteria...
As you can imagine the code takes a long, long time to run especially when running over 10,000+ records.
Does anyone have any ideas on how to speed up the code to better handle this? Is there a different logic path that I should be going down?
Help!!
sql statement to calculate rst2!variance
Do until rst1.eof
If rst1!AR = rst2!AR then
If rst1!COA = rst2!COA then
If rst1!Part_No = rst2!Part_No
rst1!Variance = rst2!Variance
rst2.movenext
rst1.movefirst
else
rst1.movenext
end if
else
rst1.movenext
end if
else
rst1.movenext
end if
loop
Unfortunately, I have about 30 of these loops in my code as I update a table with various calculated fields. The calc fields are not simple A*B, but more like sum of this group of records...count of records that meet this criteria...
As you can imagine the code takes a long, long time to run especially when running over 10,000+ records.
Does anyone have any ideas on how to speed up the code to better handle this? Is there a different logic path that I should be going down?
Help!!