Ascentient
IS-IT--Management
- Nov 4, 2002
- 267
to make things work faster. I need some assistance to see if I can make this bit of code faster with another approach.
The DSum has to scan 30,000 records (and growing) for each of 10 Material Code Fields in the table (created by my ingenious predecessor). You take this by the number of products that have to be calculated from tblReOrderLevels on a daily basis and it could eventually become very time consuming. I would like to simplify this if possible.
If more information is needed please let me know.
Ascent
Code:
'Recalc reorder levels.
Dim intTotPreviousTwelveMonths As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblReOrderLevels", dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
intTotPreviousTwelveMonths = 0
DoCmd.Hourglass True
'MsgBox rs!MATERIAL
For i = 1 To 10
intTotPreviousTwelveMonths =
intTotPreviousTwelveMonths + Nz(DSum("[QTY-SHIP-" &
i & "]", "tblBMtk", "[MATERIAL-CODE-" & i &
"]='" & [rs]![MATERIAL] & "' AND ([ORDER-DATE]
Between DateAdd(""yyyy"",-1,Now()) And Now())"), 0)
Next
rs.Edit
rs!TwelveMonthSales = intTotPreviousTwelveMonths
rs.Update
rs.MoveNext
Loop
The DSum has to scan 30,000 records (and growing) for each of 10 Material Code Fields in the table (created by my ingenious predecessor). You take this by the number of products that have to be calculated from tblReOrderLevels on a daily basis and it could eventually become very time consuming. I would like to simplify this if possible.
If more information is needed please let me know.
Ascent