Calculating a Null Value

J

jlo

I have two fields that I want to subtract from one another. However, there
will be times when the one field is null.

How can I get [field1] (500) -[field2] (blank) to give me 500?
 
J

John Spencer

Use the NZ function to force a value of zero.

[Field1] - Nz([Field2],0)

Or use the IIF function

IIF(IsNull([Field2]),[Field1],[Field1]-[Field2])

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

jlo

Thank you! That's exactly what I wanted.

John Spencer said:
Use the NZ function to force a value of zero.

[Field1] - Nz([Field2],0)

Or use the IIF function

IIF(IsNull([Field2]),[Field1],[Field1]-[Field2])

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I have two fields that I want to subtract from one another. However, there
will be times when the one field is null.

How can I get [field1] (500) -[field2] (blank) to give me 500?
 

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