[AccessD] Change in the evaluation of IIF, or something else?

Andy Lacey andy at minstersystems.co.uk
Thu Feb 5 05:08:11 CST 2015


Hi folks
 
I'm moving an ancient and very big db from A97 to A2010. I've just been tripped
up by a difference in behaviour when using IIF. Here's the line of code:
 
res=IIF(IsNull(var),Null,Weekday(var))
 
In A97 this works fine and gives me Null.  However, in A2010 this is crashing
with Invalid Use of Null. It must evaluate both true and false element(s) of the
IIF regardless. (Queries do not appear to do this, they work as before).
 
Is this a general rule in A2010.  Is there anything I can do to change this
behaviour? I know I can code round it in a number of ways but finding all
instances of this in a humungous db is a horrendous prospect. I'm praying for a
magic answer.
 
Hang on, read on.
 
After a bit more digging I'm not sure now where this will and will not arise. I
just tried the following:
 
res=iif(isnull(var),null,instr(var,"12345","1"))
 
and, unlike the Weekday function, that crashes in A97 which blows out of the
water the idea that the False part of the IIF function wasn't evaluated before.
So now I'm not sure if there is a rule by which all functions abide. 
 
Confused.
 
Oh and pleeease don't tell me that I shouldn't have coded like that in the first
place. That wouldn't be helpful.
 
Andy
 
 


More information about the AccessD mailing list