Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   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 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:

10/10/2021Copy Text from Field
10/10/2021Access for Free
10/8/2021Label Resize
10/2/2021Criticisms of Access
10/1/2021Access Developer 32
9/28/2021Track Log On

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Account Login
Online Theater
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn