Running sum on subform

M

Mike

I want to build an expression to calculate running sum off a subform.

I have
No Total Inv Cumulative Inv
1 6135.01 6135.01
2 4424.99 4424.99
3 58.25 58.25

I have want
No Total Inv Cumulative Inv
1 6135.01 6135.01
2 4424.99 10560.00
3 58.25 10618.25
 
M

M Skabialka

I found this recently to accomplish this - sorry - can't recall the source:
Create a function in a Module, using the appropriate field names as in my
example.

Private Function SubSum()
'*************************************************************
'* pkName - Existing unique fieldname (usually primarykey) *
'* sumName - Name of the field to runsum *
'* SubSum = frmRunSum(Me, "pkName", "sumName")
'*************************************************************
'Creates the running sub in the subform

If Trim(Me!ModID & "") <> "" Then 'Skip New Record!
SubSum = Format(frmRunSum(Me, "ModID", "ChargeAmount"), "Currency")
End If
End Function

In the subform, the ControlSource for the cumulated total is
=SubSum()

That's it - it works great!
Mich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top