IIF Statement with Multiple condition

drew101

New Member
Joined
Jun 14, 2017
Messages
12
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]
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,742
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
Joined
Jun 14, 2017
Messages
12
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.
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,742
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.
 

Forum statistics

Threads
1,077,738
Messages
5,335,926
Members
399,058
Latest member
elada31

Some videos you may like

This Week's Hot Topics

Top