How do I have a running total subtracted from a starting budget?

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

I want to build a report for the finance dept. that shows several accounts,
each with a starting budget with a running balance. One account should look
like this:
Purch# Desc Cost balance
Opening balance 1000
1 Pizza 10 990
2 soda 5 985
3 widgets 200 785

The account table fields:
- AccID#
- startingBudget

The Purch fields:
- Purch#
- Desc
- Cost
- AccID#
 
Hi,


SELECT a.purchNumber, LAST(a.desc), LAST(a.cost), -SUM(b.cost) As Balance
FROM myTable As a INNER JOIN myTable As b
ON a.purchNumber >= b.purchNumber
GROUP BY a.purchNumber



should do, as long as the first record is

PurchNumber Desc Cost
0 Opening balance -1000


(ie, - because it is a negative cost, it is an income)

Note also I give a PurchNumber rather than leaving it blank.



Hoping it may help,
Vanderghast, Access MVP
 
Hi,


Could that record be ALSO append to the purchases table? If not, either you
have to use manually, a constant:


SELECT a.purchNumber, LAST(a.desc), LAST(a.cost),
StartingConstant-SUM(b.cost) As Balance
FROM myTable As a INNER JOIN myTable As b
ON a.purchNumber >= b.purchNumber
GROUP BY a.purchNumber



either to somehow incorporate that table in the FROM clause which is already
sufficiently complex as it is, or something similar, or to use a non-trivial
DLookup, to read the appropriate starting constant.


Hoping it may help,
Vanderghast, Access MVP
 

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

Back
Top