Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of danfiggolf
danfiggolf

Multiple IIf Statements using And in Expression Builder
I can get the code in the attached snippet to work when I do not use an And in the statement that allows me to look at more then one COM_TYPE value, but when I do the following no dates appear in the "Recent Check" field of the Access reports.  So, If I add this code it doesn't work:

=IIf([COMP_TYPE]="COM",IIf([Date_032] Is Null,IIf([Date_031] Is Null,IIf([Date_030] Is Null,IIf([Date_029] Is Null,[Date_029],[Date_029]),[Date_030]),[Date_031]),[Date_032])) And
 IIf([COMP_TYPE]="MFD",IIf([Date_039] Is Null,IIf([Date_038] Is Null,IIf([Date_037] Is Null,IIf([Date_036] Is Null,[Date_036],[Date_036]),[Date_037]),[Date_038]),[Date_039]))

but, this returns data no problem -

=IIf([COMP_TYPE]="COM",IIf([Date_032] Is Null,IIf([Date_031] Is Null,IIf([Date_030] Is Null,IIf([Date_029] Is Null,[Date_029],[Date_029]),[Date_030]),[Date_031]),[Date_032]))

 I'm trying to retrieve the last date entered as depicted in the snapshots I sent you.  The data is inputted via our Permits application and I'm trying to grab the 1st, 2nd, 3rd, or maybe the forth date entered, if it is the last one entered.  So if it is the 3rd field that was the last used, the forth would be null.  

The code in Slide3.GIF was returning no recent data, then I tried this code and it gives me the dates for COMP_TYPE=COM but if I use "And" I get nothing again.  So the question is how can I have multiple COMP_TYPE(s) using And?

 See attached snapshots.
=IIf([COMP_TYPE]="COM",IIf([Date_032] Is Null,IIf([Date_031] Is Null,IIf([Date_030] Is Null,IIf([Date_029] Is Null,[Date_029],[Date_029]),[Date_030]),[Date_031]),[Date_032])) And
 IIf([COMP_TYPE]="MFD",IIf([Date_039] Is Null,IIf([Date_038] Is Null,IIf([Date_037] Is Null,IIf([Date_036] Is Null,[Date_036],[Date_036]),[Date_037]),[Date_038]),[Date_039]))

Open in new window

Slide1.GIF
Slide2.GIF
Slide3.GIF

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Guy Hengel [angelIII / a3]Guy Hengel [angelIII / a3]🇱🇺

if I remember correctly, in the expression builder you need to use the functional syntax of and:


IIF(AND(condition1, condition2), value_if_true, value_if_false)

Open in new window


SOLUTION
Avatar of Jeffrey CoachmanJeffrey Coachman🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

AngelIII,

That Sytax "=IF(AND(Cond1,Cond2,...),True,False)" is more for IF() ...like in Excel
(if you use it with IIF you will get a Syntax error)

IIF can have the "AND" inserted using the more literal sysnax:
    =IIf([Price]>15 And [Rate]=0.06,"Too High","Too Low")
;-)

Jeff

(Shave the Goatee yet?)
;-)

ASKER CERTIFIED SOLUTION
Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.