#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    2
    Rep Power
    0

    Query Ms Access IIf statement multiple conditions


    Is it possible to add multiple conditions in a query?

    I have built a IIf statement like this

    Answer: IIf([Combinaison]="Mike","12")

    It look at the field Combinaison and if it reads "Mike" it put the number 12 in field Answer.
    I am trying to add more iff because there is more then the word Mike in the Combinaison row


    Could it be something similar to

    Answer: IIf([Combinaison]="Mike","12")
    IIf([Combinaison]="Steve","13")
    Thanks
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,956
    Rep Power
    8618
    Code:
    SELECT IIf([Combinaison] = "Mike", 12, IIf([Combinaison] = "Steve", 13)) As Answer 
    FROM MyTable;
    Although this example screams for a second table and a relationship instead.

    Since you seem to be in design view, it would look like the attached screen shot
    Attached Images
    Last edited by medialint; June 6th, 2006 at 09:58 PM.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    2
    Rep Power
    0

    Thanks :)


    Thanks

    I was getting confused with the format but with your explanation I was managed to make it work as shown in your graphic, I also managed to put more conditions in the example provided.


    Thanks for your input

    Cheers
    Fab


    Originally Posted by medialint
    Code:
    SELECT IIf([Combinaison] = "Mike", 12, IIf([Combinaison] = "Steve", 13)) As Answer 
    FROM MyTable;
    Although this example screams for a second table and a relationship instead.

    Since you seem to be in design view, it would look like the attached screen shot

IMN logo majestic logo threadwatch logo seochat tools logo