tech on the net
Home About Us Feedback Site Map

Microsoft

Access Excel Word

Database

SQL Oracle / PLSQL SQL Server MySQL MariaDB PostgreSQL

Web Development

HTML CSS Color Picker

Language

C Language

More

ASCII Table Linux UNIX Java Clipart Joke of the Moment

Other Sites

CheckYourMath BigActivities
Share this page:

MS Access: iif Function

Learn how to use the Access iif function with syntax and examples.

Description

The Microsoft Access iif function returns one value if a specified condition evaluates to TRUE, or another value if it evaluates to FALSE.

Syntax

The syntax for the Microsoft Access iif function is:

iif ( condition, value_if_true, value_if_false )

Parameters or Arguments

condition is the value that you want to test.

value_if_true is the value that is returned if condition evaluates to TRUE.

value_if_false is the value that is return if condition evaluates to FALSE.

Applies To

The iif function can be used in the following versions of Microsoft Access:

Example

iif ([Qty] > 10, "large", "small")

would return "large" if the value in the Qty field is greater than 10. Otherwise, it would return "small".

This is equivalent to the following IF statement in VBA code.

If [Qty] > 10 Then
   result = "large"
Else
   result = "small"
End If

Example (in SQL/Queries)

You can use the iif function in a query in Microsoft Access.

Microsoft Access

In this example, if the [Time Out] field is less than or equal to 12 o'clock noon, then the iif function will return the number of hours that have elapsed between [Time Out] and [Time In]. If [Time Out] is greater than 12 o'clock noon, then the iif function will return subtract 30 minutes from the time worked.

Frequently Asked Questions


Question: How would I use the iif function if I wanted to have more than one condition?

Answer: You could use the AND keyword to include multiple conditions.

Microsoft Access

In the example above, the iif function will return "Yes" if both the ContactTitle = "Owner" and City = "Madrid". If one or both of these conditions is not met, it will return "No".