In Access, the Choose function selects and returns a value from a list of arguments based on a given position.
The syntax for the Choose function is:
Choose(index, choice-1[,choice-2, … [, choice-n]] )
You can use Choose to look up a value in a list of possibilities. If index is 1, Choose returns the first choice in the list; if index is 2, it returns the second choice, and so on. The Choose function returns a Null if index is less than 1 or greater than the number of choices listed.
index is position number in the list of values to return.
choice is variant expression containing one of the possible choices.
Example
|
VBA Code
|
This example uses the Choose function to display a fruits name in response to an index. Now the MyChoice variable would contain the value “Orange”.
SQL query
You can also use the Choose function in a query.
|