GetRows Method

The GetRows method on a Recordset object retrieves multiple records of a recordset into an array.

array = recordset.GetRows( Rows, Start, Fields )
 

Parameters

Rows
This optional parameter specifies a Long expression indicating the number of records to retrieve. The default value if this parameter is not specified is an GetRowSetEnum which is adGetRowsRest (value = -1).
Start
This optional parameter specifies the starting location for the record from which the GetRows operation should begin, which can be a bookmark or an enumeration indicating the current, first, or last record in a Recordset object. This argument is a Variant and can be either a bookmark or one of the following enumerated values for BookmarkEnum:
Enumeration Value Description
adBookmarkCurrent 0 The current record.
adBookmarkFirst 1 The first record.
adBookmarkLast 2 The last record.

This optional argument defaults to adBookmarkCurrent.

Fields
This optional parameter is a Variant and specifies a single field name or ordinal position or an array of field names or ordinal position numbers. ADO returns only the data in these fields.

Return Values

A two-dimensional array.

Remarks

The GetRows method is used to copy records from a recordset into a two-dimensional array. The first subscript of the array identifies the field and the second array subscript identifies the record number. The array variable is automatically dimensioned to the correct size when the GetRows method returns the data.

If a value is not specified for the Rows parameter, the GetRows method automatically retrieves all the records in the Recordset object. If more records are requested than are available, GetRows returns only the number of available records.

If the Recordset object supports bookmarks, you can specify at which record the GetRows method should begin retrieving data by passing the value of that record's Bookmark property.

To restrict the fields that the GetRows method returns, you can pass either a single field name/number or an array of field names/numbers in the Fields argument.

After the GetRows method is called, the next unread record becomes the current record, or the EOF property is set to True if there are no more records.