# IIF Statement with Multiple condition

#### drew101

##### New Member
Cant figure out why i am unable to get the correct response if 3 conditions state Active then give me Active ,if they all do not give me Inactive

I am building this report from Excel to Access
I am trying to duplicate this code in Excel
Code:
``````=IF(COUNTIF(D47:F47,"Inactive"),"Inactive","Active")[code]
in access
This is what i have in access [code] Total Staus: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active" And [Paylocity and GL DEPT CODE]="Active","Active","Inactive") [code]``````

### Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

#### Micron

##### Well-known Member
i am unable to get the correct response
You get either inactive or active when you shouldn't or you get something else, such as an error?
If the former, one of the values must not be what you think it is. The testing approach is to verify each value before evaluating the expression. How depends on where you are using this. Looks like a query...

#### drew101

##### New Member
My apologies it has been a while and i agree.

Here is the Excel formula that works in Excel
Rich (BB code):
``=IF(COUNTIF(D47:F47,"Inactive"),"Inactive","Active") ``

In Access Query
Rich (BB code):
``Expr1: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active" And [Paylocity and GL DEPT CODE]="Active","Active","Inactive")``
This Code or Expression is not returning the correct value that i am looking for

Example If i have in Column 1 =The word "Active "and in Column 2 =Active and Column 3 =Inactive. then the return value should state Inactive because 1 out of the 3 words is not "Active".

i was able to get 1 out of 2 to work with
Rich (BB code):
``````Expr1: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active","Active","Inactive")

I only do not receive the correct Value when it looks into all 3 and this is where i am asking for help.``````

#### drew101

##### New Member
Please disregard, this was a user error. I was using the wrong table

#### Micron

##### Well-known Member
Obviously I don't have your exact tables but an expression similar to yours works as expected.
I still don't know if your problem relates to all calculations for every record or just some records. Still guessing, but looks more and more like this is in a query so again, you have to be sure if all the field values in the records are as you expect. Maybe remove the calculated field so that the query still applies whatever criteria you have and run it and check those values.