A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Reset running sum on group level



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2010, 09:21 AM posted to microsoft.public.access.reports
Clage
external usenet poster
 
Posts: 1
Default Reset running sum on group level

Hi,

I created a report in MS Access with several group levels.
It reports kilometers by month, by car and by year.
I use the running sum functionality to create cumulatives on detail level.
My problem is that I need these cumulatives by car; I have the choice to
create running sum "Over Group" or "Over All", but neither does the right
thing for me.
If I use "Over Group" it will reset also on MONTH level; if I use "Over All"
it will not reset on CAR level as required.

Is there a solution for this?

sample:
DATE KM's KM;s CUM
CAR #1
02-01-2010 200 200
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

CAR #2
02-01-2010 200 200 ----RESET!!!!
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

TOTAL YEAR 1300





  #2  
Old January 14th, 2010, 03:28 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Reset running sum on group level

One method is to do this within the report's record source query with a
subquery. It might look something like this:

SELECT *, (Select SUM(KM) FROM tableA A WHERE A.Car = TableA.Car AND
A.Date=TableA.Date) as CumKMs
FROM TableA;

--
Duane Hookom
Microsoft Access MVP


"Clage" wrote:

Hi,

I created a report in MS Access with several group levels.
It reports kilometers by month, by car and by year.
I use the running sum functionality to create cumulatives on detail level.
My problem is that I need these cumulatives by car; I have the choice to
create running sum "Over Group" or "Over All", but neither does the right
thing for me.
If I use "Over Group" it will reset also on MONTH level; if I use "Over All"
it will not reset on CAR level as required.

Is there a solution for this?

sample:
DATE KM's KM;s CUM
CAR #1
02-01-2010 200 200
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

CAR #2
02-01-2010 200 200 ----RESET!!!!
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

TOTAL YEAR 1300





  #3  
Old January 15th, 2010, 06:26 PM posted to microsoft.public.access.reports
Dale Fye
external usenet poster
 
Posts: 2,651
Default Reset running sum on group level

Clage,

Another way, which could be significantly faster that the subquery method,
would be:

1. Change the control you are currently using for this to unbound, and get
rid of the running sum

2. In the reports declaration section declare an integer variable:

Private intCarMiles as Integer

3. In the Car group headers format event, set this value to zero:

Private Sub head_Car_Format(Cancel As Integer, FormatCount As Integer)
intCarMiles = 0
End Sub

4. In the detail sections Format event, increment the value of the variable
and store it in the unbound text field:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
intCarMiles = intCarMiles + Me.Mileage
Me.txt_Sum = intCarMiles
End Sub

HTH
Dale

"Clage" wrote in message
...
Hi,

I created a report in MS Access with several group levels.
It reports kilometers by month, by car and by year.
I use the running sum functionality to create cumulatives on detail level.
My problem is that I need these cumulatives by car; I have the choice to
create running sum "Over Group" or "Over All", but neither does the right
thing for me.
If I use "Over Group" it will reset also on MONTH level; if I use "Over
All"
it will not reset on CAR level as required.

Is there a solution for this?

sample:
DATE KM's KM;s CUM
CAR #1
02-01-2010 200 200
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

CAR #2
02-01-2010 200 200 ----RESET!!!!
03-01-2010 100 300
TOTAL MONTH 1 300
05-02-2010 150 450
06-02-2010 200 650
TOTAL MONTH 2 350

TOTAL CAR #1 650 650

TOTAL YEAR 1300







 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.