I'm struggling with a query in access. I'm using the DSUM function to calculate a cumulative total for COGS that starts over each year. The issue is that I need the cumulative total to not start over each year. I'm using the design view in access to attempt the query, but have copied the sql below (as this may be most helpful for the experts). So I need a cumulative total by Acctnbr and by Class that doesn't restart annually. Right now I can get it to a cumulative total by Acctnbr and by Class that restarts annually. I've exhausted my capabilities and am hoping for some good suggestions. Thanks.
SELECT Perpost, Year, Month, LocationCode, LocationDescription, LocationName, Class, State, LocationType, BenchmarkFacilityLocationCode, City, ZipCode, RentStartDate, RentEndDate, AcctNbr, AcctName, COGSFlag, MonthEndDate, Amount, DSum("Amount","tblUploadOccupancy(All)Flat","DatePart('m',[MonthEndDate])<=" & [Month] & " And DatePart('yyyy', [MonthEndDate])=" & [Year] & " And [AcctNbr]=" & [AcctNbr] & " And [Class]='" & [Class] & "' ") AS CumAmount INTO tblCumulativeCOGS
FROM [tblUploadOccupancy(All)Flat]
GROUP BY Perpost, Year, Month, LocationCode, LocationDescription, LocationName, Class, State, LocationType, BenchmarkFacilityLocationCode, City, ZipCode, RentStartDate, RentEndDate, AcctNbr, AcctName, COGSFlag, MonthEndDate, Amount
HAVING (((COGSFlag)="COGS"))
ORDER BY AcctNbr;
Open in new window
with thisOpen in new window
It might help if you posted some representative sample of the data. I'm not sure what you mean when you write: