IIF statement in query....need help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yappy77
    New Member
    • Apr 2010
    • 37

    #1

    IIF statement in query....need help please

    The following is my IIF statement in my query:
    Code:
    BuyerName: IIf([BuyerCode]="12W",“Buyer_Name”,IIf([BuyerCode]=“12U”,“Buyer_Name”,IIf([BuyerCode]=“12M”,“Buyer_Name”,IIf([BuyerCode]=“12X”,“Buyer_Name”,IIf([BuyerCode]=“12P”,“Buyer_Name”,IIf([BuyerCode]=“12D”,“Buyer_Name”,IIf([BuyerCode]=“EXC”,“NO_BUYER”,IIf([BuyerCode]=“FGT”,“FREIGHT”,“NA”))))))))
    Buyer_Name will be substituted with an actual name when the statement is working correctly.

    When I paste it into the query, access changes it to this and when I try to run it, it asks me for the parameter value--"12W", etc.:
    Code:
    BuyerName: IIf([BuyerCode]=[“12W”],[“Buyer_Name”],IIf([BuyerCode]=[“12U”],[“Buyer_Name”],IIf([BuyerCode]=[“12M”],[“Buyer_Name”],IIf([BuyerCode]=[“12X”],[“Buyer_Name”],IIf([BuyerCode]=[“12P”],[“Buyer_Name”],IIf([BuyerCode]=[“12D”],[“Buyer_Name”],IIf([BuyerCode]=[“EXC”],[“NO_BUYER”],IIf([BuyerCode]=[“FGT”],[“FREIGHT”],[“NA”]))))))))
    What can I do to get this to work?

    Any help would be appreciated as quickly as possible.

    Thanks,
    MS
    Last edited by NeoPa; Jul 23 '10, 12:58 PM. Reason: Please use the [CODE] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    As you can see now the code is posted within the code box, some of the quote characters you are using are not quote characters at all, but special characters used by word processors to display quotes in text so that they are slanted.

    This usually occurs when using a word processor to work on your SQL. This is never a good idea.

    I'm sure if you switch to using the correct characters (Use NotePad or any other text editor) your problems will (at least mainly) disappear.

    Welcome to Bytes!

    PS. See also Quotes (') and Double-Quotes (") - Where and When to use them for working with quotes.

    Comment

    • yappy77
      New Member
      • Apr 2010
      • 37

      #3
      Thanks so much for your help. It worked and I will keep in mind your tip for using Notepad in the future.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        I'm pleased that helped :)

        Comment

        Working...