JohnLute said:
Hi, Bruce.
That's a tricky one because there are times when it HAS to be NULL. Are you
saying that is HAS to have a value in order to properly multiply?
Yes ... you can't multiply by something that isn't a number. That's why
I suggested substituting 1 as the value, since multiplying by 1 won't
affect the outcome.
I suppose the
most logical values are 1 (no effect) and 0 (if there are no subunits,
total value is 0).
You can achieve this with
[UnitCount]*Nz([SubUnitCount],X)*[DecWtg]
Where X=0 or 1, depending on which you want.
I experimented with this:
[UnitCount]*Nz([SubUnitCount],0)*[DecWtg]
and entered "0" in [SubUnitCount] but the return was NULL. Ultimately, this
isn't going to work for me but I wanted to try it out.
That's strange; it sounds like there's a NULL somewhere else involved.
It should return zero if SubUnitCount is NULL and the other two fields
have values. If you want a zero value for the whole thing when any part
of it is NULL, you could just use
Nz([UnitCount]*[SubUnitCount]*[DecWtg],0)
I guess there's no getting around a NULL value in [SubUnitCount]...? I
suppose I could change all of the NULLS to "0" for when they're null but what
is the reason why the return is NULL?
That depends on your data, and how your tables are designed. What do
NULL values "mean" in your database -- does a NULL mean that the value
is unknown or missing, or does it mean there are no subunits? Depending
on what a NULL means, you would treat it differently. That's not clear
so far from your question.