Returns a Variant that contains an array.
Syntax
Array(arglist)
The required arglist argument is a comma-delimited list of values that are assigned to the elements of the array in the Variant. If you don't specify any arguments, Access creates a zero-length array.
Remarks
To refer to an element in an array, use the variable name followed by parentheses that contain the index number for the element that you want. In the following example, the first statement creates a variable named A as a Variant. The second statement assigns an array to A. The last statement assigns the value in the second array element to another variable.
Note
The following examples show how to use this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search, and then enter one or more terms in the search box.
Dim A As Variant
A = Array(10,20,30)
B = A(2)
The lower bound of an array created by the Array function is determined by the lower bound specified with the Option Base statement, unless Array is qualified with the name of the type library, such as VBA.Array. If you qualify it with the type library name, Array isn't affected by Option Base.
Note
A Variant that isn't declared as an array can still contain an array. A Variant variable can contain an array of any type except fixed-length strings and user-defined types. A Variant that contains an array is conceptually different from an array whose elements are of type Variant, but you access the array elements in the same way.
Example
This example uses the Array function to return a Variant that contains an array.
Dim MyWeek, MyDay
MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
' Return values assume the lower bound is set to 1 by using the
' Option Base statement.
MyDay = MyWeek(2) ' MyDay contains "Tue".
MyDay = MyWeek(4) ' MyDay contains "Thu".