show balance in a query


M

MG

please help me with this. I need to show in a query the balance as its
is incremented register by register.

For example the field i need to get is the named balanced. The transaccions
are stored by date and ammount

DATE AMOUNT BALANCE
04/21/2009 10 10
04/21/2009 20 30
10/04/2009 - 5 25
11/04/2009 15 40

I NEED TO WORK WITH THE BALANCE VALUE to find out if it it les or equal than
cero.

What I dont know is to do this in a query x=x+a
 
Ad

Advertisements

M

Marshall Barton

MG said:
please help me with this. I need to show in a query the balance as its
is incremented register by register.

For example the field i need to get is the named balanced. The transaccions
are stored by date and ammount

DATE AMOUNT BALANCE
04/21/2009 10 10
04/21/2009 20 30
10/04/2009 - 5 25
11/04/2009 15 40

I NEED TO WORK WITH THE BALANCE VALUE to find out if it it les or equal than
cero.


That is easy to do in a report by using a running sum text
box. Doing it in a query requires the use of a subquery suh
as:

SELECT T.*, (SELECT Sum(X.Amount)
FROM thetable As X
WHERE X.[datefield] <= T.[datefield]
) As Balance
FROM thetable As T

Either way, you must have a way to uniquely sort the
records. Your example records do not meet this requirement
because you might have more than one record per day.
 

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

Top