Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple if...thens (2007)

    We are generating labels to catalog library books. The labels obviously are different depending on the type of book or media. We currently are using the following code that checks if the media is DVD or VID, and uses the first three letters of the title if it is. If not, it uses the first three letters of the author's last name.

    TitleAbbrev: IIf([Media]="DVD" Or [Media]="VID",Left([Title],3),Left([Author Last Name],3))

    Now, we need to add another condition: if the Dewey Decimal Number = 921, we need to use first three letters of subject name, if not, then do the other check for the media and so on. Can someone point me in the right direction on modifying that statement properly?

    Thanks

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Multiple if...thens (2007)

    Hi there

    I think <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> this is right as it is very difficult without a working example:

    IIf([Dewey Decimal Number]="921", Left([Subject Name],3), IIf([Media]="DVD" Or [Media]="VID",Left([Title],3),Left([Author Last Name],3)),"No Code")

    I have put "No Code" at the end as an error trap in case the options are not found HTH
    Jerry

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Multiple if...thens (2007)

    I'm not sure I follow all of your choices, but you might want to investigate using the Switch function. This makes it easier to handle multiple choices.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple if...thens (2007)

    You may want to investigate "Select Case" as well...it may allow you to add in any *more* particulars you may end up needing. Example and explanation of select case here.
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  5. #5
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multiple if...thens (2007)

    Thanks a bunch! That did the trick.

    Warren

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Multiple if...thens (2007)

    Great, I was a bit worried about my answer as they are very hard to gauge. What I used is the nested IIF statement

    The basic syntax (as you know) is

    IIf(expression, truepart, falsepart)

    The trick of the nested statement is to write them seperately

    Like so:

    IIf(expression, truepart, falsepart)

    IIf(expression1, truepart1, falsepart1)

    The trick is then to join them like this:

    IIf(expression, truepart, IIf(expression1, truepart1, falsepart1))

    Personally, once they get above this I tend to run off and use the Switch function Mark mentioned or write a function that Jeremy mentioned.
    Jerry

Posting Permissions

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