599CD.com 01/01: Happy New Year   Collapse Menus
 
 
New Releases:  Access RecordsetsActive Server PagesPowerPoint dismiss
 
   
 

What's New?  |  Courses  |  Theater  |  Demo  |  Tips  |  Blog  |  Forums  |  Search  |  Help  |  Order

 
 
New Tips Added Weekly. Get Notified of New Tips & Tricks.
 
     
 
Tips & Tricks
   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 
 

Microsoft Access IIF Function

An If / Then Alternative For VBA and Query Design

Q: I want to create a query that will calculate sales tax, but ONLY for customers in my home state of NY. For other customers, I need the tax to show up as zero. How can I do this?

A: The easiest way to do this would be with the IIF function. This one function acts like an IF / THEN statement in Visual Basic. Here's the basic syntax:

=IIF(Condition, Value If True, Value If False)

For example, if I say:

=IIF(State="NY", "Yes", "No")

then the IIF function will return the word "Yes" if the State field equals "NY". Otherwise, it returns "No."

You could also use it to return the actual tax rate, like this:

=IIF(State="NY", 0.875, 0)

In this case, if the State is "NY" then the tax rate is returned, which is 0.875 (or 8.75%), otherwise a zero is returned.

If you want to use IIF in a query, just create a blank new "calculated field" out of it, like this:

TaxRate: IIF(State="NY", 0.875, 0)

Here's a screen shot from one of my tutorials:

 

Here is a FREE VIDEO TUTORIAL that will walk you through using the IIF function in detail.

I teach the concepts in this free mini tutorial in my Access 207 course. These are full courses - over 60 minutes in length each. I spend a lot more time going over how to do this, in addition to lots more tips and tricks.

 

Huge Discounts Available
When you purchase multiple classes together
Huge savings up to 50% off! Order Now.
 

You may want to read these articles from the 599CD Blog:

 

 

Need
Help?

   
Do you have questions about Word, Excel, Access, Web Design, or computers in general? Just ask us anything you'd like.
 

Get Free Tips & Tricks
 

Join our mailing list today and get information on our Free Tips & Tricks Newsletter including free video tutorials, eBooks, live seminars, and more.

Email:
Name:
Type in the word to the left:
 
Your email will be kept 100% safe and will never be given to 3rd parties.
 


CLICK HERE for a FREE lesson



Order your first 599CD course now.
Your Satisfaction is Guaranteed!


Subscribe to our RSS FeedWhat's This?

Subscribe to RSS Feed  Add to Live Bookmarks  Add to My AOL  Add to MyYahoo  Add to Google Reader or Homepage    hide  help  

599CD Home   |   Learn More   |   What's New?   |   Contact Us   |   Free Demo   |   FAQs   |   Order Now   |   Become an Affiliate   |   TechHelp   |   MYOLP   |   Jobs   |   Chat   |   Downloads   |   Handbooks  (Text)   |    Mailing List   |   Lost Passwords   |   Referral Program   |   Online Poll   |   Troubleshooter   |   Corporate / Educational / Government / Non-Profit Sales   |   Message Forums   |   Testimonials   |   Privacy Policy   |   Tips & Tricks