Report sum problem

G

Guest

I have a report that uses a query to display deposit and withdrawal amounts
from a table. I'm trying to get the report to calculate the balance at the
bottom, but using =Sum([Deposits]-[Withdrawals]) it just returns incorrect
amounts. What am I doing wrong?
Thank you.
 
D

Debra Farnham

When you say "bottom", do you mean you have placed it in the report footer?

Debra
 
G

Guest

Yes, I made that mistake earlier, but it is definitley in the report footer.
The individual totals for withdrawal and deposits work correctly
=Sum([Withdrawals])
and
=Sum([Deposts])
but it fails to subtract withdrawals from deposits and show the balance
using the syntax above.
 
D

Debra Farnham

Oops ... think I got that a little backwards

=sum([Deposits]) - Sum([Withdrawals])


Debra Farnham said:
I'm thinking you want

=Sum([Withdrawals]) - Sum([Deposits])


H2OBOWL said:
Yes, I made that mistake earlier, but it is definitley in the report
footer.
The individual totals for withdrawal and deposits work correctly
=Sum([Withdrawals])
and
=Sum([Deposts])
but it fails to subtract withdrawals from deposits and show the balance
using the syntax above.
 
X

Xfree

Steve,
What are the Nx and ,0 doing for the below statment?

Steve Schapel said:
Or...
=Sum(Nz([Deposits],0)-Nz([Withdrawals],0))

--
Steve Schapel, Microsoft Access MVP

Debra said:
Oops ... think I got that a little backwards

=sum([Deposits]) - Sum([Withdrawals])
 
S

strive4peace

NZ (not nX) is a function to convert a Null value to something else --
the second argument, optional, is what you want the value to be if the
first argument is null

If you are adding
Null + anything = Null

one way that Null can be treated like a zero is to "wrap" it in the NZ
function

when you are doing arithmetic operations with numeric fields that may
not be filled out, it is best to wrap the reference with NZ

Nz([fieldname],0) -->
1. if [fieldname] has a value, it will be used
2. if not, 0 (zero) will be used


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*



Steve,
What are the Nx and ,0 doing for the below statment?

Steve Schapel said:
Or...
=Sum(Nz([Deposits],0)-Nz([Withdrawals],0))

--
Steve Schapel, Microsoft Access MVP

Debra said:
Oops ... think I got that a little backwards

=sum([Deposits]) - Sum([Withdrawals])
 

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