Hello folks,
I have a mbd used to track donations made to our organization, I created a query (with the gracious help of vbaInet) that has in addition to the donor's info another four columns to show the donations for the past 3 years + the current year, the trouble I'm experiencing is that the query returns a separate line per-year.
Since I have 4 columns (one for each year) is not possible to make the query show 1 line per donor and have all 4 columns in the same row?
Attached please find the SQL I'm using.
Thanks in advance!
I have a mbd used to track donations made to our organization, I created a query (with the gracious help of vbaInet) that has in addition to the donor's info another four columns to show the donations for the past 3 years + the current year, the trouble I'm experiencing is that the query returns a separate line per-year.
Since I have 4 columns (one for each year) is not possible to make the query show 1 line per donor and have all 4 columns in the same row?
Attached please find the SQL I'm using.
Thanks in advance!
Code:
SELECT tblDonorDetails.ID, tblDonorDetails.Surname, tblDonorDetails.[First Name], IIf([CivilYear]=Year(Date()),[Amount] & " " & [Currency],Null) AS [This Year], IIf([CivilYear]=Year(Date())-1,[Amount] & " " & [Currency],Null) AS [Last Year], IIf([CivilYear]=Year(Date())-2,[Amount] & " " & [Currency],Null) AS [Two Years Ago], IIf([CivilYear]=Year(Date())-3,[Amount] & " " & [Currency],Null) AS [Three Years Ago], qryAverage.Average
FROM (tblDonorDetails INNER JOIN qryAverage ON tblDonorDetails.ID = qryAverage.ID) INNER JOIN tblDonations ON tblDonorDetails.ID = tblDonations.ID
WHERE (((tblDonations.CivilYear)=Year(Date())-1 Or (tblDonations.CivilYear)=Year(Date())-2 Or (tblDonations.CivilYear)=Year(Date())-3))
GROUP BY tblDonorDetails.ID, tblDonorDetails.Surname, tblDonorDetails.[First Name], tblDonations.Amount, tblDonations.Currency, tblDonations.CivilYear, tblDonations.Month, qryAverage.Average;
Last edited: