CurrentMonth = Month(CurrentDate)
CurrentYear = Year(CurrentDate)
SQL = "SELECT Spent, MONTH(Date) AS InvMonth, YEAR(Date) As InvYear FROM Invoices WHERE YEAR(Date) = '" & CurrentYear & "' AND MONTH(Date) = '" & CurrentMonth & "'"
RecordSet.Open SQL, Connection, adOpenStatic, adLockOptimistic, adCmdText
Do Until RecordSet.EOF
MTotal(i) = MTotal(i) + RecordSet.Fields("Spent")
RecordSet.MoveNext
Loop
RecordSet.Close
This is the code that I currently have to add to the total spent for this month. I want to expand this to get monthly totals for the past 12 months.
The way I do this will be to scroll backward through the CurrentMonth value, and if the CurrentMonth value reaches 0 roll, the CurrentYear value backward 1. Using the loop variable (i) to create an array of 12 values: MTotal ()
What do you guys think?
Den
source
share