Blue Claw publishes VB code on their website that does a running sum.
Unfortunately, the running sum is not set to zero when the code runs. So if you happen to run the code twice, the new output increments from the last value of the previous run.
How do you initialize the code for each run?
Thanks
Hefly
Query
Unfortunately, the running sum is not set to zero when the code runs. So if you happen to run the code twice, the new output increments from the last value of the previous run.
How do you initialize the code for each run?
Thanks
Hefly
Code:
Option Compare Database
Global GBL_Sum As Double
Public Function Init_Globals()
GBL_Sum = 0
End Function
Public Function global_add(ivalue) As Double
GBL_Sum = GBL_Sum + ivalue
global_add = GBL_Sum
End Function
Query
Code:
SELECT tbl_Nets, Global_Add ([NetAmt]) AS [Running Sum]
INTO T_Query_Results
FROM tbl_Nets;