wh00t
Registered User.
- Local time
- Today, 23:19
- Joined
- May 18, 2001
- Messages
- 264
I have been working on a database and have set a loop to calculate a value based on imported information. The problem is, when testing with basic information, the process took 2 minutes to run through the 1100 records and do the calculation, I now have some more data to 'play' with and it consists of 24000 records (which is what it will be live), I set the loop off, and after 2 1/2 hours, I ended the program, only 15000 of the records had completed. Is there a way that I can get this to run faster? or is this the best Access can do?
code below
code below
Code:
Dim Rs As Recordset
Dim db As Database
Dim CurDate As Date
Dim Actual As Double
Dim ProdIn As Double
Dim ProdOut As Double
Dim Bakery As String
Dim ItemGrp As Integer
Dim CurID As Integer
Dim PreCum As Double
Set db = CurrentDb
Set Rs = db.OpenRecordset("TotalsResults")
Rs.MoveFirst
Do While Not Rs.EOF
If Rs![Updated] = False Then
PreCum = 0
CurDate = Rs![FromDate]
Bakery = Rs![Bakery]
ItemGrp = Rs![ItemGrpID]
CurID = Rs![ID]
ProdIn = Rs![DFProductionIn]
ProdOut = Rs![DFProductionOut]
Do Until Rs.BOF
On Error Resume Next
Rs.MovePrevious
If Rs![Bakery] = Bakery And Rs![ItemGrpID] = ItemGrp Then
PreCum = Rs![CumulativeDFPlan]
Exit Do
End If
Loop
Rs.MoveFirst
Do Until Rs![ID] = CurID
Rs.MoveNext
Loop
If ProdIn = 0 And ProdOut = 0 Then
Rs.Edit
Rs![CumulativeDFPlan] = PreCum - Rs![DFActuals]
Rs![Updated] = True
Rs.Update
End If
If ProdIn = 0 And ProdOut <> 0 Then
Rs.Edit
Rs![CumulativeDFPlan] = (PreCum - Rs![DFActuals]) - ProdOut
Rs![Updated] = True
Rs.Update
End If
If ProdIn <> 0 And ProdOut = 0 Then
Rs.Edit
Rs![CumulativeDFPlan] = (PreCum - Rs![DFActuals]) + ProdIn
Rs![Updated] = True
Rs.Update
End If
If ProdIn <> 0 And ProdOut <> 0 Then
Rs.Edit
Rs![CumulativeDFPlan] = PreCum + ((ProdIn - ProdOut) - Rs![DFActuals])
Rs![Updated] = True
Rs.Update
End If
End If
Rs.MoveNext
Loop
Rs.MoveFirst
Do While Not Rs.EOF
Rs.Edit
Rs![Updated] = False
Rs.Update
Rs.MoveNext
Loop