• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

Access 07 - Cumul Sum Field that starts at 0 each Day

Hello All

I have to get a query that includes a cumulative sum field of TransAmt that starts at zero for each day and accumulates the Day's total for each consecutive ShiftID.

Attached is a stripped down db.  

I'm too stupid to figure out how to accomplish this in 1 query so it takes me 3 to get to this point BUT in the qry_CumulSum_Step3 my column or field y: is accumulating it by ShiftID but I tried copying that query to a qry_TEST and adding a criteria for the field [BusDay] (which is my Day field) but I get #Error.
?????

My code is
SELECT qry_CumulSum_Step2.ShiftID, qry_CumulSum_Step2.BusDay, qry_CumulSum_Step2.CashFdActID, qry_CumulSum_Step2.TransAmtTtl, Val(DSum("TransAmtTtl","qry_CumulSum_Step2","ShiftID <=" & [a].[ShiftID] & " AND #[BusDay]# <=#" & [a].[BusDay] & "#")) AS y
FROM qry_CumulSum_Step2 INNER JOIN qry_CumulSum_Step2 AS a ON (qry_CumulSum_Step2.ShiftID = a.ShiftID) AND (qry_CumulSum_Step2.BusDay = a.BusDay);

Open in new window

EE-Cumulative-Sum-Q.accdb
0
wlwebb
Asked:
wlwebb
  • 3
1 Solution
 
als315Commented:
Cumulative sums always need more then one query, so it is impossible to do it in one query. You can, of course, use nested queries. It will look like one query, but you will have one select inside another select. Dsum is also query, so you should count it also :)
0
 
wlwebbAuthor Commented:
Any Idea on why I get #error when I add the [BusDay] field as a part of my criteria?

PS....

I'm also working on your post from the other thread.... you guys make this seem so simple ;-))))  !!!!  And Thank YOU!
0
 
wlwebbAuthor Commented:
DUHHHHH!!!!!


Wasn't putting the "#" in the right places!!!!
0
 
wlwebbAuthor Commented:
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!

I GOT IT FINALLY......!!!!!!!!!!!!!!
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now