Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   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 LinkedIn Email Richard Rost
Click here to sign up for more FREE tips

 

 

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
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
PCResale.NET
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
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 1/25/2025 6:34:43 PM. PLT: 0s