I have searched for help on this and have not been successful in finding an answer to my particular problem.
I am trying to compute a running sum of sales in a query.
Here is the query output as of now:
The "gross" column is the amount of sales in that particular month. I would like the "progress" field to be the running sum.
As you can see, I've made some progress (using the Microsoft Northwind database sample and this link: http://support.microsoft.com/kb/205183
However, notice how the last cell (for March) goes back to $152,000 instead of adding to the prior total.
Also, I would like the module to maintain the current total for the rest of the year. That is, for the months of April through September, I'd like to current progress to appear (about $185mm).
Here is the module code I am using:
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Option Explicit
- Function bbrunsum(production_month As Date, gross_amount As Currency) As Long
- Static pro_month As Date
- Static gross As Currency
- If pro_month = production_month Then
- pro_month = production_month
- gross = gross_amount
- Else
- gross = gross + gross_amount
- End If
- bbrunsum = gross
- End Function
Thanks,
Brian