Can you use a report to display this information? Reports has a Running Sum property for an object. Or use could use VB in the report to keep a running sum.
If you want it in a query, you could create a function in a module. You would have your running total dimmed in the global area so it isn’t reset each time the query calls the function. You would need to keep track of when control grouping changes so you can clear the running sum. One of the columns in the query would reference the function like:
RunningTotal: GetRunningTotal(PartNo, Amount)
Also, make sure your query has the proper sorting and grouping.
Your function might look like this:
Option Compare Database
Dim RunningTotal as double, PrevPartNo as String
Function GetRunningTotal (PartNo As String, Amount As Double) As Double
If IsNull(PrevPartNo) or PrevPartNo <> PartNo Then
PrevpartNo = PartNo ‘PartNo changed or first time through the function
RunningTotal = Amount ‘start RunningTotal over for new or first part
RunningTotal = RunnintTotal + Amount
GetRunningTotal = RunningTotal ‘Pass back the current value of running total