Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Adding in Build

Status
Not open for further replies.

ProgEval

MIS
Sep 21, 2006
59
0
0
US
In a query I am adding four fields together in a new field. I am doing the calculation in build. It looks like this...

NewField: Field1 + Field2 + Field3 + Field4

This works fine as long as a have a number entered into every field. Although, if one field is blank, it does not add the others together.

What do I need to do to get it to add the fields even if one or more have a null value?

Thanks!
 
I figured it out.

NewField: nz(Field1) + nz(Field2) + nz(Field3) + nz(Field4)
 
I always attempt to be more explicit:
NewField: nz(Field1[red],0[/red]) + nz(Field2[red],0[/red]) + nz(Field3[red],0[/red]) + nz(Field4[red],0[/red])

It also raises a red flag when values (possibly including nulls) are summed across fields rather than across records.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top