If statements in access NESTED

cardonas

Registered User.
Local time
Today, 04:30
Joined
Dec 30, 2015
Messages
16
I am new to access and I am trying to combined two IF statements I tried them below in access query and they work separately but when I put them together the query doesn’t run I am not sure why? Any help would greatly be appreciated

The statements below work perfectly separate but I want to put them together? Please

BMI Pass?: IIf(([Qualified for 2015?]="yes" Or [Qualified for 2015?]="No visit in 2015") And ([BMI Screen Confirmed?]="yes" Or [BMI Screen Confirmed?] Is Null Or [BMI Screen Confirmed?]=" ") And ([BMI Calculated]="No" Or [BMI Calculated] Is Null Or [BMI Calculated]=" "),"Fail","Pass")


IIF(([Qualified for 2015?]="yes" Or [Qualified for 2015]="No visit in 2015") And ([BMI Screen Confirmed?]="yes" Or [BMI Screen Confirmed?] Is Null Or [BMI Screen Confirmed?]=" ") And ([BMI Calculated]="yes") And ([BMI Normal]="No" Or [BMI Normal] Is Null Or [BMI Normal]=" ") And ([BMI Plan]="no" Or [BMI Plan] Is Null Or [BMI Plan]=" "),"Fail,"Pass")
Need to combined the two above If statements please?? Any help would greatly be appreciated!!!


This is the criteria I am looking for
First Criteria
Qualified for 2015= “Yes” or “no visit in 2015”
BMI Screen Confirmed = “Yes” or Is Null or “ “
BMI Calculated = “No” or Is Null or “ “
Results are “Fail”

Second Criteria
Qualified for 2015= “Yes” or “no visit in 2015”
BMI Screen Confirmed = “Yes” or Is Null or “ “
BMI Calculated = “Yes”
BMI Normal= “No” or Is null or “ “
BMI Plan = “No” Is Null or “ “
Results are “Fail”

:banghead::confused:
 
If you have to nest this many IFs then either:
make a table to join and lookup your answers
or
build a function to give a field, and return your answer.
 
If they work seperately, it should be easy to combine them. You would surround the logic portion of both of them with a set of parenthesis, then copy the logic of one of them to the other and put an OR between them. You essentially have this:

Field1: IIf(A AND B AND (C OR D), "Fail", "Pass")
Field2: IIf(E AND (F OR G OR H) AND (I OR J), "Fail", "Pass")

Surround the logic of both with parenthesis:

(A AND B AND (C OR D))
(E AND (F OR G OR H) AND (I OR J))

Combine them and seperate with an OR:

(A AND B AND (C OR D)) OR (E AND (F OR G OR H) AND (I OR J))

Then take that and replace the logic in one of your fields with it.
 
Ah!! Thank you Plog I just realize the query runs but now I am getting (-1) as a result in my column?? So looks like the IIF:( statements are not working...
 
PLOG!! YOU'RE:D THE BEST!!! I followed your logic and it work !! Thank you again!!
 

Users who are viewing this thread

Back
Top Bottom