Access IIF not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agivler

    #1

    Access IIF not working

    I am trying to do a multiple Iif function in Access 2002 but it needs to check multiple fields and doesn't seem to get past the first set in the Iif.

    Code:
    IIf(([DATADUMP1-10].[Edition 1] Is Not Null And [DATADUMP1-10].[Status 1] Is Not Null) Or ([DATADUMP1-10].[Edition 1] Not Like "PN" And [DATADUMP1-10].[Status 1] Not Like "S") Or([DATADUMP1-10].[Edition 2] Not Like "PN" And [DATADUMP1-10].[Status 2] Not Like "S") Or ([DATADUMP1-10].[Edition 3] Not Like "PN" And [DATADUMP1-10].[Status 3] Not Like "S") Or ([DATADUMP1-10].[Edition 4] Not Like "PN" And [DATADUMP1-10].[Status 4] Not Like "S") Or ([DATADUMP1-10].[Edition 5] Not Like "PN" And [DATADUMP1-10].[Status 5] Not Like "S") Or ([DATADUMP1-10].[Edition 6] Not Like "PN" And [DATADUMP1-10].[Status 6] Not Like "S") Or ([DATADUMP1-10].[Edition 7] Not Like "PN" And [DATADUMP1-10].[Status 7] Not Like "S") Or ([DATADUMP1-10].[Edition 8] Not Like "PN" And [DATADUMP1-10].[Status 8] Not Like "S") Or ([DATADUMP1-10].[Edition 9] Not Like "PN" And [DATADUMP1-10].[Status 9] Not Like "S") Or ([DATADUMP1-10].[Edition 10] Not Like "PN" And [DATADUMP1-10].[Status 10] Not Like "S"),"Subscriber","NonSubscriber") AS Expr1,
    Any help would be appreciated. I realize this is older but that is what they have me using.
    Last edited by NeoPa; Nov 18 '10, 04:23 PM. Reason: Added CODE tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Originally posted by Agivler
    Agivler:
    and doesn't seem to get past the first set in the Iif.
    What on Earth do you mean by this? What does "not getting past" even mean?

    What actually happens? What error message do you get? What makes you think there is a problem at all? What points you to there being a problem in the first set? What is a set even?

    If you give us a question that makes sense I expect we can help you, but not from this I'm afraid.

    Comment

    • agivler

      #3
      Sorr I am viewing each part of the Iif as a set. So it seems to give me the correct data when it goes through this part
      Code:
      IIf(([DATADUMP1-10].[Edition 1] Is Null And [DATADUMP1-10].[Status 1] Is Null) Or ([DATADUMP1-10].[Edition 1] Not Like "PN" And [DATADUMP1-10].[Status 1] Not Like "S")
      but then it seems to skip
      Code:
      Or ([DATADUMP1-10].[Edition 2] Not Like "PN" And [DATADUMP1-10].[Status 2] Not Like "S") Or ([DATADUMP1-10].[Edition 3] Not Like "PN" And [DATADUMP1-10].[Status 3] Not Like "S") Or ([DATADUMP1-10].[Edition 4] Not Like "PN" And [DATADUMP1-10].[Status 4] Not Like "S") Or ([DATADUMP1-10].[Edition 5] Not Like "PN" And [DATADUMP1-10].[Status 5] Not Like "S") Or ([DATADUMP1-10].[Edition 6] Not Like "PN" And [DATADUMP1-10].[Status 6] Not Like "S") Or ([DATADUMP1-10].[Edition 7] Not Like "PN" And [DATADUMP1-10].[Status 7] Not Like "S") Or ([DATADUMP1-10].[Edition 8] Not Like "PN" And [DATADUMP1-10].[Status 8] Not Like "S") Or ([DATADUMP1-10].[Edition 9] Not Like "PN" And [DATADUMP1-10].[Status 9] Not Like "S") Or ([DATADUMP1-10].[Edition 10] Not Like "PN" And [DATADUMP1-10].[Status 10] Not Like "S"),"NonSubscriber","Subscriber")
      Last edited by NeoPa; Nov 18 '10, 05:19 PM. Reason: Please use the CODE tags!!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Originally posted by Agivler
        Agivler:
        I am viewing each part of the Iif as a set.
        As I have no idea what uou mean by part or set this is still pretty unhelpful. If I told you I was separating the SQL up into distinct blobs, would that mean anything to you? I expect not. Communication is like that. If you use words that have no defined meaning within a context then I won't understand what you're trying to say.

        You then go on to repeat yourself. Pretty unhelpful when I still don't understand what you're trying to say.

        To help the situation, and bring some understanding into the question I asked specific questions. This means that even if your communication skills are very poor, all you would need to do to progress would be to answer the questions that I ask. Unfortunately you seem to have ignored them completely.

        I really can't help you if you ignore what I say. Whether I want to or not (and I generally like to help where I can) I simply can't help you if I have no idea what you're talking about.

        Comment

        • agiv

          #5
          No blobs don't mean anything to me. I have just been thrown into using Access and not fimilar with all the correct terminology. Let me try this.

          I need to search for a null field and then also search through Edition 1 (thru 10) and Status 1 (thru 10). Yes, I know there has to be a better way then search through 10 fields each but that is the way they have the data and it can't be changed.

          This part of the statement seems to work and return the correct result
          Code:
          IIf(([DATADUMP1-10].[Edition 1] Is Null And [DATADUMP1-10].[Status 1] Is Null) Or ([DATADUMP1-10].[Edition 1] Not Like "PN" And [DATADUMP1-10].[Status 1] Not Like "S")
          but when I add on the following it just seems to ignore it
          Code:
          Or ([DATADUMP1-10].[Edition 2] Not Like "PN" And [DATADUMP1-10].[Status 2] Not Like "S") Or ([DATADUMP1-10].[Edition 3] Not Like "PN" And [DATADUMP1-10].[Status 3] Not Like "S") Or ([DATADUMP1-10].[Edition 4] Not Like "PN" And [DATADUMP1-10].[Status 4] Not Like "S") Or ([DATADUMP1-10].[Edition 5] Not Like "PN" And [DATADUMP1-10].[Status 5] Not Like "S") Or ([DATADUMP1-10].[Edition 6] Not Like "PN" And [DATADUMP1-10].[Status 6] Not Like "S") Or ([DATADUMP1-10].[Edition 7] Not Like "PN" And [DATADUMP1-10].[Status 7] Not Like "S") Or ([DATADUMP1-10].[Edition 8] Not Like "PN" And [DATADUMP1-10].[Status 8] Not Like "S") Or ([DATADUMP1-10].[Edition 9] Not Like "PN" And [DATADUMP1-10].[Status 9] Not Like "S") Or ([DATADUMP1-10].[Edition 10] Not Like "PN" And [DATADUMP1-10].[Status 10] Not Like "S"),"NonSubscriber","Subscriber") AS Expr1,
          Unfortunately I need to check all these fields but am wondering if it is too much for Access 2002 to handle.
          Last edited by NeoPa; Nov 18 '10, 05:42 PM. Reason: Added CODE tags again

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            Originally posted by Agiv
            Agiv:
            No blobs don't mean anything to me.
            Of course they don't. No more do parts or sets mean anything to me, or anybody else for that matter, unless and until you clarify what you mean by answering my questions.
            Originally posted by Agiv
            Agiv:
            Let me try this.
            You're welcome to try that, but I should tell you that until you start answering my questions I will completely ignore anything you post. It's only basic courtesy after all. That and putting the CODE tags around your code as I've commented on for each of your posts so far.

            Comment

            • JKing
              Recognized Expert Top Contributor
              • Jun 2007
              • 1206

              #7
              In your if statement you are using multiple ORs. If just one of those conditions evaluates to true the entire if statement returns true.

              If you need all conditions to be met then you would need to use AND not OR.
              Last edited by NeoPa; Nov 19 '10, 04:42 PM. Reason: This should be moved to the access forum. Done - but OP gets no notification as he's a public poster.

              Comment

              Working...