Re: Help with DSum to create running sum
- From: Opal <tmwelton@xxxxxxxxxxx>
- Date: Wed, 12 Nov 2008 08:19:48 -0800 (PST)
On Nov 11, 7:44 pm, MGFoster <m...@xxxxxxxxxxx> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Yes you can use query fields in the DSum() function:
RunTotal:DSum("CostSavingsperYear/250000","Activity",
"Left(Activity,12) = '" & Left(A.Activity,12) & "'")
You'll have to alias the table Activity as A in the main query for this
to work. It would look like this in the SQL view:
FROM Activity As A
In Design View you'd right click on the table and select Properties -
then change the Alias property from the table name to it's Alias - A.
Notice I used single quotes to delimit the Left(A.Activity,12) in the
DSum() function, 'cuz it returns a string that will be compared to
Left(Activity,12).
BTW, you shouldn't have a column (field) with the same name as the
table, it can be confusing; and, it doesn't truly identify the column's
data: what type of Activity? ion_activity, event_activity,
game_activity, etc.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBSRom1IechKqOuFEgEQIm8wCdF03y32gfnBCuQKWqyOvnfxzXUssAoOy+
UloY963C6IwiBN3CW68ar8El
=choc
-----END PGP SIGNATURE-----
Opal wrote:
I am trying to create a query that will show a running
sum of a calculated field as this query builds a chart.
Here is my SQL prior to adding a DSum expression:
SELECT Left([Activity],12) AS ActivityName,
[CostSavingsperYear]/250000 AS CostReduction,
10.37 AS Target
FROM Activity
GROUP BY Left([Activity],12),
[CostSavingsperYear]/250000, 10.37
ORDER BY [CostSavingsperYear]/250000;
(The Activity field in the Table is a memo field so I
am only collecting the first 12 characters as the
value on the X-axis for the chart.)
I want to create a running sum of the
Cost Reduction field, but am stuck on the
DSum expression. I tried:
RunTotal:DSum("CostReduction","qryCostReduction",
"[Activity]<=" & [ActivityName] & "")
No doubt I cannot use the DSum against fields in the query.
So how do I achieve the desired results? Dies anyone
have any advice?- Hide quoted text -
- Show quoted text -
Thanks for your help, MG.... but I still have a problem.
You stated that I need to:
"In Design View you'd right click on the table and select Properties
-
then change the Alias property from the table name to it's Alias - A."
I cannot find that option. I am running Access 2003, btw.
Secondly, yes you are correct, I should rename the Activity field, and
I have - to CostActivity so my SQL for the query looks like:
SELECT Left([CostActivity],12) AS ActivityName,
[CostSavingsperYear]/250000 AS CostReduction,
10.37 AS Target,
DSum("CostSavingsperYear/250000","Activity","Left(CostActivity,12) =
'" & Left([A].[CostActivity],12) & "'") AS RunTotal
FROM Activity AS A
GROUP BY Left([CostActivity],12), [CostSavingsperYear]/250000, 10.37
ORDER BY [CostSavingsperYear]/250000;
Unfortunately, I am getting the same values in both the
CostSavingsperYear
field and the RunTotal field. The RunTotal field is not producing a
running
sum. Can you see the problem?
.
- Follow-Ups:
- Re: Help with DSum to create running sum
- From: Opal
- Re: Help with DSum to create running sum
- References:
- Help with DSum to create running sum
- From: Opal
- Re: Help with DSum to create running sum
- From: MGFoster
- Help with DSum to create running sum
- Prev by Date: Want to build a query to return quarterly data
- Next by Date: My append query and I dont understand each other
- Previous by thread: Re: Help with DSum to create running sum
- Next by thread: Re: Help with DSum to create running sum
- Index(es):
Relevant Pages
|
Loading