calculated total in query

  • Thread starter Thread starter Song
  • Start date Start date
S

Song

I have 2 fields in query. Qty1 and Qty 2. I added Total:qty1+qty2.
However, if qty1 has some number but qty2 is blank, my total is blank,
instead of just show the sum.
 
In Access

You need to use the NZ function to force a ZERO. Or use an IIF clause.

Total: Nz(Qty1,0) + Nz(Qty2,0)

or

Total: IIF(Qty1 is Null,0,Qty1) + IIF(Qty2 is Null,0,Qty2)

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