Results 1 to 5 of 5

Thread: IIF Statement with Multiple condition
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2017
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default IIF Statement with Multiple condition

    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]

  2. #2
    Board Regular
    Join Date
    Jun 2015
    Location
    Ontario, Canada
    Posts
    1,698
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: IIF Statement with Multiple condition

    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...
    Tips for posting problems:
    1) "doesn't work" doesn't help. Post error message text/numbers and/or state what's happening.
    2) if posting code or sql, use code tags; specify on which code line errors occur, if applicable
    3) try to be specific; assume we know nothing about your issue - because we don't!

    Make all suggested changes in copies of your database or to its objects.

    "1 out of 1010 people understand binary. The other 1001 don't."

  3. #3
    New Member
    Join Date
    Jun 2017
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: IIF Statement with Multiple condition

    My apologies it has been a while and i agree.

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

    In Access Query
    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 [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.

  4. #4
    New Member
    Join Date
    Jun 2017
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: IIF Statement with Multiple condition

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

  5. #5
    Board Regular
    Join Date
    Jun 2015
    Location
    Ontario, Canada
    Posts
    1,698
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: IIF Statement with Multiple condition

    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.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •