How do I get totals with blank fields (Nulls)?

C

CJ

I work for a non-profit that gives people money for Gas, Rent, Food, ect. I
built a simple table with each category in a field. I need a report that
sums each category and totals all money spent for a specific period. With
help from Karl (from here) I was able to build a query that pulls the info I
need. I then built a second query based on the first to get 'sums' for each
field and then added an expression that totals the sums. This field reads:
Total: [SumOfGas]+[SumOfRent] . . ect. My report worked great until I pulled
up a date that had only one field with an amount. The query showed the sum
but nothing was in the total field. After researching I know it has
something to do with blank fields (Nulls) but I'm just to inexperienced to
know how to write the expression and where to put it to get the total field
to populate. This is the last piece to my project. Can anyone help me out?
 
J

John Spencer MVP

You need to use the NZ function to handle the nulls
Nz([SumOfGas],0) + Nz([SumOfRent],0) + ...

Nz returns the value of the field unless it is null, then it returns 0 (or
whatever you have entered as the second argument).

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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