Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Boston
    Posts
    1

    Unanswered: Multiple IIF Statements?

    I need to query a field and return several different values based on the text in the field. Example if text = T01 then field value should = Sell Fail. I have up to 10 different codes in a given field that need to be associated with a given value. How do I associate them all so only the correct one comes up in the Query? Thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Sao Paulo - Brazil
    Posts
    16
    Hi


    You can use choose() or switch(). But if you use more than 10 options, i think better you create a new table with the codes and link in your query

    take a look in help about choose e switch syntax
    Regards,

    Rogerio

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    best way by far is to put those 10 values into a lookup table

    create table textlookup
    ( textcode char(3)
    , textvalue varchar(20) )

    insert into textlookup
    values ('T01','Sell Fail')
    insert into textlookup
    values ('T02','Buy Succeed')
    etc.

    select A.foo, A.bar, B.textvalue
    from yourtable A
    , textlookup B
    where A.textfield = B.textcode

    rudy

Posting Permissions

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