1. 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. 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

3. 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.

4. 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.

5. Re: Multiple if...thens (2007)

Thanks a bunch! That did the trick.

Warren

6. 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.

Posting Permissions

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