Solved

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

Posted on 2014-02-16
4
411 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending email from List Data 2 51
Run Time Error 3071 26 40
How to make query not show results in table form go straight to report 4 21
error 3022 in access vba 3 14
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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

867 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

25 Experts available now in Live!

Get 1:1 Help Now