Microsoft Access
--
Questions
--
Followers
Top Experts
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_03 0]),[Date_ 031]),[Dat e_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_03 7]),[Date_ 038]),[Dat e_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_03 0]),[Date_ 031]),[Dat e_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.
Slide2.GIF
Slide3.GIF
=IIf([COMP_TYPE]="COM",IIf
IIf([COMP_TYPE]="MFD",IIf(
but, this returns data no problem -
=IIf([COMP_TYPE]="COM",IIf
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]))
Slide1.GIFSlide2.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.
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)
SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
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?)
;-)
That Sytax "=IF(AND(Cond1,Cond2,...),
(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
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
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.