Perhaps I don't understand what you are trying to do.
AUUUGH!!!!!!
Testing the wrong way
Areasq: IIf(Abs([ODLength] is Not Null + [ODWidth] is Not Null + [ODHeight] Is
Not Null) IN (2,3), Nz([ODLength],1)*Nz([ODWidth],1)*Nz([ODHeight],1),Null)
or
Areasq: IIf(Abs(IsNull([ODLength])+IsNull([ODWidth])+IsNull([ODHeight]))IN
(0,1),Nz([ODLength],1)*Nz([ODWidth],1)*Nz([ODHeight],1),Null)
In words, if there are zero or one null value then calculate, but if there 2
or 3 nulls just return null.
The reason for the abs is just to strip of adding three true (-1) values. You
could drop the abs and use In (0,-1) as the test
Areasq: IIf(IsNull([ODLength])+IsNull([ODWidth])+IsNull([ODHeight])IN
(0,-1),Nz([ODLength],1)*Nz([ODWidth],1)*Nz([ODHeight],1),Null)
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Well, I had never encountered Abs and had to look it up! Still not
sure I fully understand it but...I gave it a whirl and it returns
Null:
-If all have values (yes!).
-If two have values and one is null (drat! this is when it needs to
multiply the two).
If one has a value and the other two are Null then it returns the
value from the non-null field (super drat!).
Since I don't fully understand Abs I can't see how to edit the code -
if it can be done at all.
Returns a value of the same type that is passed to it specifying the
absolute value of a number.
The required number argument can be any valid numeric expression. If
number contains Null, Null is returned; if it is an uninitialized
variable, zero is returned.
The absolute value of a number is its unsigned magnitude. For example,
ABS(-1) and ABS(1) both return 1.
Try it this way.
Areasq: IIf(Abs(IsNull([ODLength])+IsNull([ODWidth])+IsNull([ODHeight]))IN
(2,3),Nz([ODLength],1)*Nz([ODWidth],1)*Nz([ODHeight],1),Null)
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
(e-mail address removed) wrote:
I've been fiddling with this:
Areasq: IIf(IsNull([ODLength])+IsNull([ODWidth])
+IsNull([ODHeight])>=0,Null,IIf(IsNull([ODLength])+IsNull([ODWidth])
+IsNull([ODHeight])<1,Nz([ODLength],1)*Nz([ODWidth],1)*Nz([ODHeight],
1),Null))
Obviously, I still have the problem of "1" being returned when all are
Null. Is there any way I can work that out? I threw in the first IIf
to return Null if two fields are Null and it seems to work.
Thanks for you continued help!
IF you mean the value is Null then you can use the formula below.
NZ(IDL,1) * NZ(IDW,1) * Nz(IDH,1)
There are two potential problems with this. If all the values arenull, the
formula will return 1. If two values are null, the formula will return the
value in the non-null field.
If that is a problem then test to see if more than one is null
IIF(IsNull(IDL)+IsNull(IDW)+IsNull(IDH)<-1,NZ(IDL,1)*NZ(IDW,1)*Nz(IDH,1),Null)
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
(e-mail address removed) wrote:
Three fields:
IDL
IDW
IDH
When each field has data then they're calculated to arrive at a cubic
value. The trick is to calculate an area value when only two fields
have data.
The possible combinations are:
IDLxIDW
IDLxIDH
IDWxIDH
Does anyone have a simple approach to this? I can write the code but
with my skills it will most likely be ridiculously long and
inefficient.
Thanks for any help you might have!- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -