Home page
or browse popular tags
Access Functions

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

Access: Choose Function


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.


Choose(1, "Have", "a", "nice", "day")            returns "Have"
Choose(3, "Have", "a", "nice", "day")            returns "nice"
Choose(4, "Have", "a", "nice", "day")            returns "day"
Choose(7, "Have", "a", "nice", "day")            returns NULL
Choose(2.87, "Have", "a", "nice", "day")         returns "a"

VBA Code

Dim MyChoice As String
MyChoice = Choose(2, "Apple", "Orange", "Strawberry")

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.

SELECT Choose([OwnerID],'Table','Desc','Chair','Mirrow') AS Expr1
FROM Orders

If you'd like to see how it works, enter SQL statement and press Execute


Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments

Copyright © 2005-2023             www.WebCheatSheet.com All Rights Reserved.