DSum to return previous change totals for each change number

T

Todd H

I am trying to calculate a running sum that calculates the previous
changes for any current change for each contract. I think the DSum is
the best route, but I cannot get the expression to filter the correct
records; currently it totals all the records.

The function should return the sum of the [PCOFinalCost] for the
previous [PCCO_No]'s for each different [PTCContractID] unless the
[PCCO_No] is 1. If it is the first PCCO, then the previous change
total is 0.

Here is the expression:

=IIf([PCCO_No]=1,0,
(DSum("PCOFinalCost","qryPCCOData","[qryPCCOData.PTCContractID] = _
'[PTCContractID]'" And "[qryPCCOData.PCCO_No] between '1' and
'([PCCO_No]-1)'")))



Any help would be appreciated
 
G

Guest

Try something like:

=IIf([PCCO_No]=1,0, DSum("PCOFinalCost", "qryPCCOData",
"PTCContractID = '" & [PTCContractID] & "' And PCCO_No Between 1 and " &
[PCCO_No]-1 ))

This is assuming PTContractID is text and PCCO_No is numeric.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Grand Totals In Report Footer for Separate Groups 3
DSUM in Group Footer 6
DSUM 7
DSum Type Mismatch 3
DSUM? 7
report totals 4
Ms Access Dsum help? 0
Nested IIF expr not evaluating 2nd condition and beyond. 2

Top