How do I add together more than 2 fields? I have number fields.

  • Thread starter Thread starter stevemetsch
  • Start date Start date
S

stevemetsch

I have several fields listing different sizes of T shirts that are all the
same price. I want to add the fields (of each record) together and then
multiply by the price. I tried normal mathematical notation without any
success.
 
You probably have null (no value) for some quantity. Try:


( (Nz( qty1, 0) + Nz( qty2, 0) + ... + Nz( qtyN, 0) ) * unitPrice


Vanderghast, Access MVP
 
I have several fields listing different sizes of T shirts that are all the
same price.

In that case your table structure is WRONG. "Fields are expensive, records are
cheap"; you should have one *record* per item (size of tshirt), not a separate
field for each size.
I want to add the fields (of each record) together and then
multiply by the price. I tried normal mathematical notation without any
success.

You'll get a NULL result if any of the individual field values is NULL (say
you have a field for XXXL but nothing in that field). You can use the NZ
function to convert Null to Zero, e.g.

(NZ([XS]) + NZ() + NZ([M]) + NZ([L]) + NZ([XL])) * [UnitCost]

but you'll be much better off having five records instead of five fields, and
using a Totals query to sum them.
 

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

Back
Top