What a coincidence, I just posted a very simular procedure in another formum. Here is the response I posted. Hope it helps...
Subject: Re: [AccessDevelopers] Running Sum
This is a hard one. Here is one approach that I took.
1. Add a field to your table called RunningSum.
2. In your form add a private procedure to your form called TheSum()
This procedure will cycle thru your records and calculate a running
sum.
(note: I called the field that has the values to be added MyNums)
Private Sub TheSum()
Dim db As Database
Dim rst As Recordset
Dim intCnt As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("MyTable"
Do Until rst.EOF
rst.Edit
intCnt = intCnt + rst!MyNums 'this is the field we are summing
rst!RunningSum = intCnt
rst.Update
rst.MoveNext
Loop
Me.Refresh
End Sub
3. Now add a button to refresh call the proc and refresh the screen.
Private Sub cmdSum_Click()
Call TheSum
End Sub
This is a simple approach and may need modifying if you have a special
sort in the form's recordset. Try it and see if it works. Let me know
where it may need modifying.
ljprodev@yahoo.com
ProDev, MS Access Applications B-)