[AccessD] IIf with three fields

Jim Dettman jimdettman at verizon.net
Wed Mar 29 14:22:52 CDT 2017


Kostas,
  
 I would write a function as nested IIf()'s get messy and are hard to
follow.  Also both true/false expressions are always evaluated, so it can be
slower.

 But what I would suggest is:

 IIf(NZ([Mobile],"")="","","Mobile: " & [Mobile]) &
IIf(NZ([phone_home],"")="",""," Home: " & [phone_home]) &
IIf(NZ([phone_job],"")="",""," Job: " & [phone_job])

 so you get a nicely formatted string with any combination of numbers you
might have.

Jim. 

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Kostas Konstantinidis
Sent: Wednesday, March 29, 2017 02:59 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] IIf with three fields

Hi all,
I am a little confused about how to make IIf to work in query with three
different phones fields while all or any of them may be null

I use 

IIf([mobile] Is Null; [phone_home]; IIf([phone_home] Is Null; [phone_job];
IIf([phone_job] Is Null; 
[phone_home] & ", " & [mobile]; [phone_job] & ", " & [phone_home] & ", " &
", " & [mobile])))

But it doesn't work in all cases

Any help please?
Thank's
/kostas



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list