|
-
Oct 4th, 2005, 01:27 AM
#5
Re: Balance Field in MS Access
If you had designed the database with two fields: credit and debit, then you would have been able to create an additional field that is a subquery for the running balance.
The subquery would be something like...
select table.*, (Select (Sum(debit) - sum(credit)) FROM table_alias where table_alias.datetime <= table.datetime and table_alias.id <= table.id) as runbalance
from table
You have to have a means of identifying which records come before the current record... I used date and time combioned with autoinc id (on second thought you can use just that (without the date) instead). table_alias is the same table but contains records only up to the current record in table.
Last edited by leinad31; Oct 4th, 2005 at 02:50 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|