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]
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Micron

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

Watch MrExcel Video

Forum statistics

Threads
1,101,768
Messages
5,482,801
Members
407,363
Latest member
lauren1932

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top