Dear Brian:
The query can now be written:
SELECT Field1, Field2,
(SELECT SUM(Field1 - Field2) + 30 FROM YourTable T1
WHERE T1.[date] <= T.[date]) AS Field3
FROM YourTable T
ORDER BY [date]
Please pay careful attention to these notes:
- Replace YourTable in the query with the actual name of your table.
- Replace Field1, Field2, and [date] with the actual names of the
columns in your table.
- I am seriously wondering if [date] is unique. If you ever have two
rows in the table with the same [date] value then this isn't going to
work. As I stated initially, you must uniquely order the rows if you
want the running sum (your Field3) to work the way you probably expect
it to work. If you have an autonumber column or some other column
that can be included to make the ordering unique then you need to
specify it so I can make a better query here.
- I just stuck the value 30 in because you've given me no information
about how this can be derived.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts