473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dsum issue

http://support.microsoft.com/default...b;en-us;208714

in the KB article above it gives a detailed explanation of how to do a
running sum in a query. However in this article they only do the
running sum for 1 year. When I run this on multiple years the running
sum starts over for each year. Can anyone tell me how to run this over
multiple years.

thanks,
KO

Nov 13 '05 #1
8 2723
I just tried the example they have and I show that the running sum is from
the start of the recordset. It isn't starting over each year. However, I was
able to make it start over each year by replacing

[OrderDate])<=" & [AYear] & "")

in #6 with

[OrderDate])=" & [AYear] & "")

Also, to go over multiple years, just remove the part in #8. Even with that
criteria in there, it limited what year was being shown, but the sum was
still over all of the years unless you changed <= to =.

--
Wayne Morgan
MS Access MVP
"turtle" <ko****@vistacontrols.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
http://support.microsoft.com/default...b;en-us;208714

in the KB article above it gives a detailed explanation of how to do a
running sum in a query. However in this article they only do the
running sum for 1 year. When I run this on multiple years the running
sum starts over for each year. Can anyone tell me how to run this over
multiple years.

thanks,
KO

Nov 13 '05 #2
Wayne,
When I run the query my runtot: column starts over for each year.
Here is the data that I get. I have no idea why I would get something
different from you. Can anyone else try to run it.

ayear amonth SumOfFreight RunTot fdate
1996 7 $1,288.18 1288.18 Jul
1996 8 $1,397.17 2685.35 Aug
1996 9 $1,123.48 3808.83 Sep
1996 10 $1,520.59 5329.42 Oct
1996 11 $2,151.86 7481.28 Nov
1996 12 $2,798.59 10279.87Dec
1997 1 $2,238.98 2238.98 Jan
1997 2 $1,601.45 3840.43 Feb
1997 3 $1,888.81 5729.24 Mar
1997 4 $2,939.10 8668.34 Apr
1997 5 $3,461.40 12129.74May
1997 6 $1,852.65 13982.39Jun
1997 7 $2,458.72 17729.29Jul
1997 8 $3,078.27 22204.73Aug
1997 9 $3,237.05 26565.26Sep
1997 10 $3,945.53 32031.38Oct
1997 11 $2,008.85 36192.09Nov
1997 12 $3,757.96 42748.64Dec
1998 1 $5,463.44 7702.42 Jan
1998 2 $4,272.94 13576.81Feb
1998 3 $5,379.02 20844.64Mar
1998 4 $6,393.57 30177.31Apr
1998 5 $685.08 34323.79May

Nov 13 '05 #3
Will you post the SQL of your query. You've added one more column than is in
the example.

--
Wayne Morgan
MS Access MVP
"turtle" <ko****@vistacontrols.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Wayne,
When I run the query my runtot: column starts over for each year.
Here is the data that I get. I have no idea why I would get something
different from you. Can anyone else try to run it.

ayear amonth SumOfFreight RunTot fdate
1996 7 $1,288.18 1288.18 Jul
1996 8 $1,397.17 2685.35 Aug
1996 9 $1,123.48 3808.83 Sep
1996 10 $1,520.59 5329.42 Oct
1996 11 $2,151.86 7481.28 Nov
1996 12 $2,798.59 10279.87Dec
1997 1 $2,238.98 2238.98 Jan
1997 2 $1,601.45 3840.43 Feb
1997 3 $1,888.81 5729.24 Mar
1997 4 $2,939.10 8668.34 Apr
1997 5 $3,461.40 12129.74May
1997 6 $1,852.65 13982.39Jun
1997 7 $2,458.72 17729.29Jul
1997 8 $3,078.27 22204.73Aug
1997 9 $3,237.05 26565.26Sep
1997 10 $3,945.53 32031.38Oct
1997 11 $2,008.85 36192.09Nov
1997 12 $3,757.96 42748.64Dec
1998 1 $5,463.44 7702.42 Jan
1998 2 $4,272.94 13576.81Feb
1998 3 $5,379.02 20844.64Mar
1998 4 $6,393.57 30177.31Apr
1998 5 $685.08 34323.79May

Nov 13 '05 #4
Sorry if this double posts.... i added the freight column to see what
it was calculating. It doesn't work with it in or out of the query.

SELECT DatePart("yyyy",[orderdate]) AS ayear, DatePart("m",[orderdate])
AS amonth, Sum(Orders.Freight) AS SumOfFreight,
Format(DSum("Freight","Orders","DatePart ('yyyy', [OrderDate])<=" &
[Ayear] & " and DatePart('m', [OrderDate])<=" & [Amonth] &
""),"$0,000.00") AS RunTot, Format([orderdate],"mmm") AS fdate
FROM Orders
GROUP BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm")
ORDER BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm");

Nov 13 '05 #5
Wayne,
The extra field is just the freight field.... I was checking to see if
it was adding.

SELECT DatePart("yyyy",[orderdate]) AS ayear, DatePart("m",[orderdate])
AS amonth, Sum(Orders.Freight) AS SumOfFreight,
Format(DSum("Freight","Orders","DatePart ('yyyy', [OrderDate])<=" &
[Ayear] & " and DatePart('m', [OrderDate])<=" & [Amonth] &
""),"$0,000.00") AS RunTot, Format([orderdate],"mmm") AS fdate
FROM Orders
GROUP BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm")
ORDER BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm");

Nov 13 '05 #6
I copied and pasted your SQL into a new query and ran it. This is what I got.

ayear amonth SumOfFreight RunTot fdate
1996 1 $6,098.00 $6,098.00 Jan
1997 1 $205.00 $6,303.00 Jan
1997 2 $5,555.00 $11,858.00 Feb
I manually added the items in the table. The values depicted are correct. Have you applied the most current Office and Jet service packs?

--
Wayne Morgan
MS Access MVP
"turtle" <ko****@vistacontrols.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com...
Sorry if this double posts.... i added the freight column to see what
it was calculating. It doesn't work with it in or out of the query.

SELECT DatePart("yyyy",[orderdate]) AS ayear, DatePart("m",[orderdate])
AS amonth, Sum(Orders.Freight) AS SumOfFreight,
Format(DSum("Freight","Orders","DatePart ('yyyy', [OrderDate])<=" &
[Ayear] & " and DatePart('m', [OrderDate])<=" & [Amonth] &
""),"$0,000.00") AS RunTot, Format([orderdate],"mmm") AS fdate
FROM Orders
GROUP BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm")
ORDER BY DatePart("yyyy",[orderdate]), DatePart("m",[orderdate]),
Format([orderdate],"mmm");

Nov 13 '05 #7
I am using Mircrosoft Access 2002 (10.4302.4219) SP-2
and msjet40.dll

Is that right?

Nov 13 '05 #8
Office 2002 is on SP3 and Jet 4 is at SP8. The version number of msjet40.dll
in SP8 is 4.0.8015.0. To get this number, right click on msjet40.dll,
choose Properties, and go to the Version tab.

--
Wayne Morgan
MS Access MVP
"turtle" <ko****@vistacontrols.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I am using Mircrosoft Access 2002 (10.4302.4219) SP-2
and msjet40.dll

Is that right?

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success....
1
by: Dalan | last post by:
This seems a bit odd, but I have not been able to persuade Access 97 to format several DSum total columns in Currency - Standard format. It appears to be defaulting to a general number format...
2
by: Dalan | last post by:
I seemed to be having problems with structuring the use of NZ with a DSum expression. Having tried numerous variations of the expression without success, I'm asking for assistance. First some...
0
by: Dalan | last post by:
I have a select query with a few DSum expressions, but when I add a between and ending date parameter to Date Sold, the results show #Error in two (discount and net sales) of the four gross total...
1
by: Marc Aube | last post by:
Is there a web site that can ofer some help. The quotation marks are posing an issue as well as other items for this function. I have some books but they are not consistent in their use of the code...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
3
by: technocraze | last post by:
Hi community experts, I am having an isue with Dsum function that is used to count the total number for a particular field (intake) at the textbox afterupdate event with condition/ criteria...
3
patjones
by: patjones | last post by:
Good morning all: In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending...
9
by: BlackJack17 | last post by:
Alright you all have been so helpful with everything else that I thought I'd run one more issue by you. I have put together a report that is driven by a query. This query (Unique Records) returns...
19
by: dozingquinn | last post by:
Hello, Thanks to a previous helper I found some great Dsum info here: http://www.mvps.org/access/general/gen0018.htm Unfortunately I can't get the code to work for my requirements. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.