MaxRecords Property

 

Description

 

Indicates the maximum number of records to return to a Recordset from a query.

 

Sets or returns a Long value that indicates the maximum number of records to return. Default is zero (no limit).

 

PowerBASIC Syntax

 

PROPERTY GET MaxRecords () AS LONG

PROPERTY SET MaxRecords (BYVAL lMaxRecords AS LONG)

 

Parameter (GET MaxRecords only)

 

lMaxRecords

LONG. A value that indicates the maximum number of records to return. Default is zero (no limit).

 

Return Value (SET MaxRecords only)

 

LONG. The maximum number of records to return

 

Remarks

 

Use the MaxRecords property to limit the number of records that the provider returns from the data source. The default setting of this property is zero, which means the provider returns all requested records.

 

The MaxRecords property is read/write when the Recordset is closed and read-only when it is open.

 

Problem

 

Using the MaxRecords property of an ADO Recordset object does not affect the number of records returned in queries against Microsoft Access databases.

 

The MaxRecords property depends on functionality exposed by the underlying OLE DB provider or ODBC driver to limit the number of rows returned by the query. This functionality is optional for ODBC drivers and OLE DB providers. The Microsoft Access ODBC driver and Jet OLEDB provider do not expose this functionality. This behavior may occur for other OLE DB providers and ODBC drivers as well.

 

If you want to limit the number of records returned in a query against a Microsoft Access database, use the TOP syntax in the query string rather than the Recordset's MaxRecords property.

 

For example:

 

SELECT TOP 2 EmployeeID, LastName, FirstName FROM Employees ORDER BY LastName, FirstName;

 

or

 

SELECT TOP 20 PERCENT EmployeeID, LastName, FirstName FROM Employees ORDER BY LastName, FirstName;

 

Valid XHTML 1.0 Transitional