Undefined function iff in expression (1 Viewer)

MushroomKing

Registered User.
Local time
Yesterday, 22:45
Joined
Jun 7, 2018
Messages
100
Hey guys! Could someone help me maybe? I have no idea what im not getting.
I used this type of expression/statement before, but now i dont understand.


I made a new field with the following code in the field name:

buildsize: iff([volume_m3]<0,"smaller")

But i get an undefined function iff in expression.

Thanks in advance people!:cool:
 

isladogs

MVP / VIP
Local time
Today, 05:45
Joined
Jan 14, 2017
Messages
18,186
The function is IIf and it has three parts
Iif(some condition, result if true, result if false)

So you need something like
Code:
buildsize: IIf([volume_m3]<0,"smaller","same or bigger")
 

MushroomKing

Registered User.
Local time
Yesterday, 22:45
Joined
Jun 7, 2018
Messages
100
Thanks ISLA :)

That did it. I should have know also...

Just one more, where i calculate, but i get the same error.
Again i dont see this one either :S

checkorder: iff([cocota]<[rusty],"Total too high","Total too low")
 

plog

Banishment Pending
Local time
Today, 00:45
Joined
May 11, 2011
Messages
11,613
Iif will work with just 2 parameters:

buildsize: iif([volume_m3]<0,"smaller")

What you did is type Iff (with 2 f's) and not Iif (with 2 I's), thus the undefined function.
 

MushroomKing

Registered User.
Local time
Yesterday, 22:45
Joined
Jun 7, 2018
Messages
100
Damn...i feel ashamed.

Kinda need to get used to the fact that its double anyway. Coming from PHP background :D


Thanks! would not have found out because its so silly
 

isladogs

MVP / VIP
Local time
Today, 05:45
Joined
Jan 14, 2017
Messages
18,186
As plog rightly says IIf will work without a false clause and defaults to an empty string for text.
However if you try doing that with a numerical comparison such as IIf(3>4,1), Access throws a compile error
Similarly comparing two dates without a false clause.

Of course, Iff that you wrote again will never work

BTW my spell checker automatically replaces 'plog' with plot. So if I ever reply with that I haven't lost the plot (probably...) :rolleyes:
 

plog

Banishment Pending
Local time
Today, 00:45
Joined
May 11, 2011
Messages
11,613
I don't get a compile error for:

Test: IIf(3>4,1)

Nor for this:

Test2: IIf(Date()>Date(),1)
 

isladogs

MVP / VIP
Local time
Today, 05:45
Joined
Jan 14, 2017
Messages
18,186
I tested both in the immediate window. For example as attached screenshot
 

Attachments

  • Capture.PNG
    Capture.PNG
    11.3 KB · Views: 174

plog

Banishment Pending
Local time
Today, 00:45
Joined
May 11, 2011
Messages
11,613
I did mine in a query and worked fine.
 

isladogs

MVP / VIP
Local time
Today, 05:45
Joined
Jan 14, 2017
Messages
18,186
Interesting. I've just repeated both tests using a query and as you say, both work.
I suspect behind the scenes, the query optimizer is adding a null false value in each case.
Either way, I prefer to add a false value so I have 'control' over the output
 

Users who are viewing this thread

Top Bottom