V
Vina
I have a function to calculate the running sum but when I
close the query or re-run it it remembers the last sum
and end up subtracting the wrong amt. How can I add
something in this function that will reset the Running
total when the query is closed or everytime the query
gets run again it will be a fresh calculation. The only
way I can get a fresh calculation is when I close the
database.
Function fncRunSum(lngCatID As Long, lngOhnd As Long,
lngUnits As Long) As Long
Static lngID As Long
Static lngAmt As Long
If lngID <> lngCatID Then
lngID = lngCatID
lngAmt = lngOhnd - lngUnits
Else
lngAmt = lngAmt - lngUnits
End If
fncRunSum = lngAmt
End Function
close the query or re-run it it remembers the last sum
and end up subtracting the wrong amt. How can I add
something in this function that will reset the Running
total when the query is closed or everytime the query
gets run again it will be a fresh calculation. The only
way I can get a fresh calculation is when I close the
database.
Function fncRunSum(lngCatID As Long, lngOhnd As Long,
lngUnits As Long) As Long
Static lngID As Long
Static lngAmt As Long
If lngID <> lngCatID Then
lngID = lngCatID
lngAmt = lngOhnd - lngUnits
Else
lngAmt = lngAmt - lngUnits
End If
fncRunSum = lngAmt
End Function