Solved

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

Posted on 2014-02-16
4
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 40

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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.

726 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