IIF statement error ??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I try to make following IIF statement

IIF([Unit]="FCL","each"+[contweight]) ------>> getting #erro

IIF([Unit]="FCL",[contweight]) that is Okay, ----but I need the word "each" in the query/repor

What is wrong in the first line ??

William
 
William

In your first statement, replace the plus sign + with ampersand &. I would also put a space after
"each ". Hopefully this should do it.

IIF([Unit]="FCL","each "&[contweight])


Andrew L.
 
Andrew's suggestion of using & rather than + should work. I'm surprised,
though, that the 2nd statement works, since IIf requires 3 parameters, not
2. The 3rd parameter tells it what to use if the results of the first
parameter are false.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


petrovlis said:
I try to make following IIF statement:

IIF([Unit]="FCL","each"+[contweight]) ------>> getting #error

IIF([Unit]="FCL",[contweight]) that is Okay, ----but I need the
word "each" in the query/report
 
Doug,

Depends what you mean by "requires". If you don't provide a 'falsepart'
argument, IIf() returns Null when the 'condition' is false. This is, of
course, undocumented, but I must admit I have done this myself many
times over the years, with no resultant grief.
 
My understanding (from working in dBase for 20 years!) is that the third element in Iif() is not
obligatory.

Very often it is "", and this is assumed by default.

Andrew L.

Douglas J. Steele said:
Andrew's suggestion of using & rather than + should work. I'm surprised,
though, that the 2nd statement works, since IIf requires 3 parameters, not
2. The 3rd parameter tells it what to use if the results of the first
parameter are false.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


petrovlis said:
I try to make following IIF statement:

IIF([Unit]="FCL","each"+[contweight]) ------>> getting #error

IIF([Unit]="FCL",[contweight]) that is Okay, ----but I need the
word "each" in the query/report
What is wrong in the first line ???

William
 
Andrew,

This is not correct. See my earlier post. If the "third element" is
not specified, the IIf() function returns Null, not "".
 
Back
Top