Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Posts
    59

    Lightbulb Unanswered: using IIf with Concatination

    hello

    i have a column named type in which "buy" and "Sell" are stored along with other details in their respective columns
    i was trying to build a concatenation query in which buy should be seen as "Bought" and sell as "Sold". heres what my query looks like

    ((IIf([type]="SELL", "Sold",iff([type]="BUY", "Bought"))
    & " " & lots & " Lots"& " of " & item & " (" &security.description& ")" & " @" &price & " Closed@"&cprice ) as s

    the comma after "Sold" is creating problems i tried to replace it by & but of no use

    Can anyone help me

    Thankyou

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    it is not the comma.
    that iff should be iif

    what happens if neither SELL nor BUY ??

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    May 2004
    Posts
    65
    My immediate comment would be the incorrect number of parenthesis ((((( )))
    also im not sure if the first two are required.

    Second comment would be - if there are only two options - but and sell then you don't need to test the second iif.

    IIf([type]="SELL", "Sold", "Bought")

    Third thought would be to change the " to '

    Hope that helps

Posting Permissions

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