Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   News   Courses   Tips   Templates   Forums   Help   Order   Contact   Logon  
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List


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.

UPDATE: I covered the IIF function again, in more detail, in my Access 2013 Expert Level 8 class.


By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost
Click here to sign up for more FREE tips


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


Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Account Login
Online Theater
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Waiting List
Production Schedule
Collapse Menus
Live Chat
Customer Support
WalkThru Tutorials
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
MYOLP Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Live Chat
General Info
Support Policy
Contact Form
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

YouTube Channel    LinkedIn

Blog RSS Feed