ACC97: Differences Between MaxRecords and TopValues PropertiesID: Q183244
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article describes the differences between the MaxRecords property and
the TopValues property.
The MaxRecords property sets or returns the maximum number of records of a
query on an ODBC table and is useful in situations where limited client
resources prohibit management of large numbers of records from ODBC tables.
The TopValues property is useful when you want to return certain records
based on a specified percentage. MaxRecords is only for ODBC data sources,
not for queries on tables contained in the database, and is available in
Visual Basic.
The TopValues property returns a specified number of records or a
percentage of records that meet the criteria you specify in the design of a
query on any table. TopValues is not available in Visual Basic but can be
used on tables contained in the database or ODBC tables. To set the amount
of records, TopValues requires a percent sign (%).
TopValues can return a number or a percentage, whereas MaxRecords sets or
returns only a number of records.
Sub MaxRecordsX()
Dim dbsCurrent As Database
Dim qdfPassThrough As QueryDef
Dim qdfLocal As QueryDef
Dim rstTemp As Recordset
' Open a database from which QueryDef objects can be created.
Set dbsCurrent = OpenDatabase("DB1.mdb")
' Create a pass-through query to retrieve data from
' a Microsoft SQL Server database.
Set qdfPassThrough = dbsCurrent.CreateQueryDef("")
' Set the properties of the new query, limiting the
' number of returnable records to 20.
qdfPassThrough.Connect = _
"ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers"
qdfPassThrough.SQL = "SELECT * FROM titles"
qdfPassThrough.ReturnsRecords = True
qdfPassThrough.MaxRecords = 20
Set rstTemp = qdfPassThrough.OpenRecordset()
' Display results of query.
Debug.Print "Query results:"
With rstTemp
Do While Not .EOF
Debug.Print , .Fields(0), .Fields(1)
.MoveNext
Loop
.Close
End With
dbsCurrent.Close
End Sub
Additional query words: top values max records
Keywords : QryProp
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: April 20, 1999