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/9/2021Birthdays
10/8/2021Label Resize
10/2/2021Criticisms of Access
10/1/2021Access Developer 32
10/1/2021Groups
9/29/2021DMin
9/28/2021Track Log On
9/26/2021Sliders
 

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

YouTube Channel    LinkedIn