A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Error in IIf Expression



 
 
Thread Tools Display Modes
  #1  
Old January 4th, 2010, 04:33 PM posted to microsoft.public.access.queries
Pamela
external usenet poster
 
Posts: 193
Default Error in IIf Expression

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
  #2  
Old January 4th, 2010, 04:41 PM posted to microsoft.public.access.queries
Bob Barrows
external usenet poster
 
Posts: 475
Default Error in IIf Expression

Pamela wrote:
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,"
--
HTH,
Bob Barrows


  #3  
Old January 4th, 2010, 04:52 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Error in IIf Expression

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" wrote:

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

  #4  
Old January 4th, 2010, 04:59 PM posted to microsoft.public.access.queries
Pamela
external usenet poster
 
Posts: 193
Default Error in IIf Expression

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" wrote:

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" wrote:

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

  #5  
Old January 4th, 2010, 05:27 PM posted to microsoft.public.access.queries
Bob Barrows
external usenet poster
 
Posts: 475
Default Error in IIf Expression

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]),

Pamela wrote:
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" wrote:

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" wrote:

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


--
HTH,
Bob Barrows


  #6  
Old January 4th, 2010, 05:58 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Error in IIf Expression

On Mon, 4 Jan 2010 08:52:01 -0800, KARL DEWEY
wrote:

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, ...

--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:19 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.