herbertioz
Registered User.
- Local time
- Today, 22:42
- Joined
- Nov 6, 2009
- Messages
- 66
Hi all!
I have a recordset and need to calculate a running sum in the table "scale1". It works with one weight put into the table one for one, but not when you put in multiple records with weights.
I know I can use DSum(). Some suggestions on runningsum with recordset?
I have a recordset and need to calculate a running sum in the table "scale1". It works with one weight put into the table one for one, but not when you put in multiple records with weights.
I know I can use DSum(). Some suggestions on runningsum with recordset?
Code:
Dim d As Database
Dim v1 As Recordset
Dim Weight1 As Field
Dim Sum1 As Double
Set d = CurrentDb()
Set v1 = d.OpenRecordset("scale1")
Set Weight1 = v1.Fields("Weight")
While Not v1.EOF
Sum1 = (Sum1 + Weight1) / 1000
v1.Delete
v1.MoveNext
Wend
v1.Close