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,743
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,743
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,078,515
Messages
5,340,861
Members
399,396
Latest member
PBE

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top