Error in IIf Expression

P

Pamela

I have an expression in my query to create a concatenated text depending upon
the value of control Measurements. If the control is skipped - meaning that
there are no Measurements, I'd like to return an expression to that extent.
Here's my expression:
Expr1: IIf([Measurements]=Null,"The damage is not such that it has a
measurement height.","The height of the damage is " & [Measurements] & "
inches.")
I'm not getting an error, but I'm not getting it to read the True statement.
It reads even the Null value as False and returns "The height of the damage
is inches. Please help me see what I'm missing here! Thanks so much!
Pamela
 
B

Bob Barrows

Pamela said:
I have an expression in my query to create a concatenated text
depending upon the value of control Measurements. If the control is
skipped - meaning that there are no Measurements, I'd like to return
an expression to that extent. Here's my expression:
Expr1: IIf([Measurements]=Null,"The damage is not such that it has a
measurement height.","The height of the damage is " & [Measurements]
& " inches.")
I'm not getting an error, but I'm not getting it to read the True
statement. It reads even the Null value as False and returns "The
height of the damage is inches. Please help me see what I'm missing
here! Thanks so much! Pamela

Nothing is ever equal to Null. Something either Is or Is Not Null. So
the immediate change is :

IIf([Measurements] Is Null,"
 
K

KARL DEWEY

Maybe it is not null but a zero lenght string.
Use this --
Expr1: IIf([Measurements]=Null OR [Measurements]="","The damage is not such
that it has a measurement height.","The height of the damage is " &
[Measurements] & " inches.")
 
P

Pamela

Thanks, Karl,
But that still didn't do it. I had actually tried that same thing earlier
instead of the "Null" but I now tried it w/ the OR as you suggested and I
still get the same thing: "The height of the damage is inches."
Any other ideas???

KARL DEWEY said:
Maybe it is not null but a zero lenght string.
Use this --
Expr1: IIf([Measurements]=Null OR [Measurements]="","The damage is not such
that it has a measurement height.","The height of the damage is " &
[Measurements] & " inches.")

--
Build a little, test a little.


Pamela said:
I have an expression in my query to create a concatenated text depending upon
the value of control Measurements. If the control is skipped - meaning that
there are no Measurements, I'd like to return an expression to that extent.
Here's my expression:
Expr1: IIf([Measurements]=Null,"The damage is not such that it has a
measurement height.","The height of the damage is " & [Measurements] & "
inches.")
I'm not getting an error, but I'm not getting it to read the True statement.
It reads even the Null value as False and returns "The height of the damage
is inches. Please help me see what I'm missing here! Thanks so much!
Pamela
 
B

Bob Barrows

I repeat:

IIf([Measurements]=Null

will always return false. Nothing is ever considered to be equal to
Null. At the very least, you need to change it to:

IIf([Measurements] Is Null

or use the IsNull() function:

Iif(IsNull([Measurements]),
Thanks, Karl,
But that still didn't do it. I had actually tried that same thing
earlier instead of the "Null" but I now tried it w/ the OR as you
suggested and I still get the same thing: "The height of the damage
is inches."
Any other ideas???

KARL DEWEY said:
Maybe it is not null but a zero lenght string.
Use this --
Expr1: IIf([Measurements]=Null OR [Measurements]="","The damage is
not such that it has a measurement height.","The height of the
damage is " & [Measurements] & " inches.")

--
Build a little, test a little.


Pamela said:
I have an expression in my query to create a concatenated text
depending upon the value of control Measurements. If the control
is skipped - meaning that there are no Measurements, I'd like to
return an expression to that extent. Here's my expression:
Expr1: IIf([Measurements]=Null,"The damage is not such that it has a
measurement height.","The height of the damage is " &
[Measurements] & " inches.")
I'm not getting an error, but I'm not getting it to read the True
statement. It reads even the Null value as False and returns "The
height of the damage is inches. Please help me see what I'm
missing here! Thanks so much! Pamela
 
J

John W. Vinson

Maybe it is not null but a zero lenght string.
Use this --
Expr1: IIf([Measurements]=Null OR [Measurements]="","The damage is not such
that it has a measurement height.","The height of the damage is " &
[Measurements] & " inches.")

Can I offer you a cup of my excellent Costa Rican coffee, Karl? <g>

Bob's right - the problem is the =Null expression. It will never be TRUE (in
fact any expression X=NULL will always be NULL, and treated as if it were
FALSE).

A safe and (surprisingly to me) fast expression is

IIf(Len([Measurements] & "") = 0, ...
 

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

Similar Threads

Access Building a IIF expression in Access 0
iif statement what is wrong with this expression 2
Dlookup Expression Error 2
Access Query problem 1
Building iif expression 2
iif Expression Error 6
IIf Statement Error 3
Nested IIf Statements 5

Top