Solved

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

Posted on 2014-02-16
4
408 Views
Last Modified: 2014-02-16
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
Comment
Question by:wlwebb
  • 3
4 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 39862524
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
 

Author Comment

by:wlwebb
ID: 39862531
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
 

Author Comment

by:wlwebb
ID: 39862536
DUHHHHH!!!!!


Wasn't putting the "#" in the right places!!!!
0
 

Author Closing Comment

by:wlwebb
ID: 39862550
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!
THANK YOU!!!!

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now