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 DigMinecraft
Share this page:

MS Access: Choose Function

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

Description

The Microsoft Access Choose function returns a value from a list of values based on a given position.

Syntax

The syntax for the Microsoft Access Choose function is:

Choose ( position, value1, value2, ... value_n )

Parameters or Arguments

position is position number in the list of values to return.

value1, value2, ... value_n is a list of values.

Note

If position is less than 1, the Choose function will return a null value.

If position is greater than the number of values, the Choose function will return a null value.

If position is a fraction (not an integer value), it will be rounded to the nearest whole number.

Applies To

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

Example

Choose(1, "Tech", "on", "the", "Net") would return "Tech"
Choose(2, "Tech", "on", "the", "Net") would return "on"
Choose(3, "Tech", "on", "the", "Net") would return "the"
Choose(4, "Tech", "on", "the", "Net") would return "Net"
Choose(5, "Tech", "on", "the", "Net") would return NULL
Choose(3.75, "Tech", "on", "the", "Net") would return "the"

Example (in VBA Code)

The Choose function can be used in VBA code in Microsoft Access. For example:

Dim LValue As String

LValue = Choose(1, "Tech", "on", "the", "Net")

In this example, the variable called LValue would contain "Tech" as a value.

Example (in SQL/Queries)

You can also use the Choose function in a query in Microsoft Access.

Microsoft Access

In this example, if the SupplierID field is 1, then the Choose function will return "IBM".
If the SupplierID field is 2, then the Choose function will return "HP".
If the SupplierID field is 3, then the Choose function will return "Nvidia".