How do I obtain a running sum for ungrouped items?

S

Skip in Virginia

I need to created a running sum expression in a query, and due to the nature
of the query, cannot group or sort by the selection criteria (the selected
records must be sorted with a different field).
 
J

John Vinson

On Sat, 29 Jan 2005 16:05:02 -0800, "Skip in Virginia" <Skip in
I need to created a running sum expression in a query, and due to the nature
of the query, cannot group or sort by the selection criteria (the selected
records must be sorted with a different field).

Must this sum be *IN THE QUERY*? It's easy on a Report - set the
Running Sum property of a textbox.

If you need it in a Query, you can use an expression

RunningSum: DSum("[FieldToSum]", "[QueryName]", "[Sortfield] <= " &
[Sortfield])

making appropriate substitutions for fieldnames. There is no
requirement that the fields used as criteria be the same as the fields
used for sorting; I'm not sure why you see this as posing a problem!

John W. Vinson[MVP]
 
Top