Calclating totals - Sum fails on empty column - Rookie

A

Atlas

I have a simple form in continuos view. I have placed a textbox in the
form's footer to calculate totals of 2 "money" column (SQL Server), with the
control code:

=Sum([MYVAL1]) + Sum([MYVAL2])

If at least one value is set in both the columns the function works. If one
of the two columns has no values the function fails. It doesn't display any
"#error" in the text box, it simply blanks the contenent.

Example:

Row MYVAL1 MYVAL2
1 10
2
3 20

Works and returns: 30


Row MYVAL1 MYVAL2
1
2 50
3

Doesn't work and returns nothing (empty)

Any hint?
 
R

Rod Scoullar

Atlas,

Adding a Null to anything produces a Null as a result. This means one of
your totals remains Null.

Try Nz(Sum([MyVal1),0) + Nz(Sum([MyVal2]),0)

Rod Scoullar.
 
A

Atlas

Try Nz(Sum([MyVal1),0) + Nz(Sum([MyVal2]),0)

Rod now it works fine!

Thanks (rookie improving....)
 

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