On Thu, 9 Nov 2006 13:21:02 -0800, B. Levien
<(E-Mail Removed)> wrote:
>I have a form with four cost fields, which have a currency format:
>
>Costs
>Costs2
>Costs3
>Costs4
Then your table is incorrectly designed. If you have a one (whatever)
to many (costs) relationship, a much better design would use THREE
tables:
YourTable <don't know what it represents>
SomeField <primary key>
CostTypes
CostType <your Costs, Costs2 etc. > <primary key>
Costs
SomeField <link to your table>
CostType <link to CostTypes>
Amount <currency>
Thus if you ever need a FIFTH cost, you can simply add it rather than
redesigning your table, all your queries, all your forms, and all your
calculations.
>I can get them to add up using the following formula:
>
>=Nz([Costs]+[Costs2]+[Costs3]+[Costs4])
>
>My problem is that all 4 fields must have a currency value in order to add
>up (so I have to put $0.00 in fields with no information). How to I get the
>four fields to add up, if 1 to 3 of them do not have a value at all?
Wrap EACH of the costs in NZ. What you're doing here is getting a NULL
result - anything plus null is NULL - and *then* setting that to zero.
=NZ([Costs]) + NZ([Costs2]) + NZ([Costs3]) + NZ([Costs4])
will convert each NULL to a zero *first* - and since $12.50 + 0 =
$12.50, you'll get the right sum.
But... normalize your data, and use a Totals query; simply don't ENTER
any record if there is no cost for that category.
John W. Vinson[MVP]
|