>
> Great stuff Phil! thanks
> One thing i forgot to mention. I might have several customers that i would
> like to repeat this data for.
>
> Customer|Jan|feb|Mar|Apr|
> Cust 1 | 5 | 8| 15| 21|
> Cust 2 | 4 | 7 | 20| 32|
> etc...
>
> Is this doable using your technique above?
> thanks
> Kolsby
>
You make things very difficult, but it has the advantage that providing there
is a customerID, you don't need to run InitGlobals
OK, a slighly different function
Option Compare Database
Option Explicit
Global GBLSum As Double
Dim OldID As Long
Public Function InitGlobals()
GBLSum = 0
End Function
Public Function GlobalAddX(ivalue, ID As Long) As Double
If ID <> OldID Then
OldID = ID
InitGlobals
End If
GBLSum = GBLSum + ivalue
GlobalAddX = GBLSum
End Function
Query8 becomes
SELECT Sum(Payments.PaymentAmount) AS SumOfPaymentAmount,
Payments.PaymentMethodID, CStr(Year([PaymentDate])) & " - " & CStr
(Format(Month([PaymentDate]),"00")) AS Dt FROM Payments
GROUP BY Payments.PaymentMethodID, CStr(Year([PaymentDate])) & " - " &
CStr(Format(Month([PaymentDate]),"00")), Year([PaymentDate]),
Month([PaymentDate]) ORDER BY Payments.PaymentMethodID, Year([PaymentDate]),
Month([PaymentDate]);
for PaymentMethodID you will use CustomerID
The bit about months & year formats the date as 2011 - 02 for Feb 2011.
Unless you do that, the date order goes wrong to you get month 1, (Jan),
month 11 (Nov), Month 12 (Dec), Month 2 (Feb) etc.
Query9 becomes
TRANSFORM Min(GlobalAddX([SumOfPaymentAmount],[PaymentMethodID])) AS
RunningSum SELECT Query8.PaymentMethodID
FROM Query8
GROUP BY Query8.PaymentMethodID
PIVOT Query8.Dt;
Phil