MaxRecords Property Example

This example uses the MaxRecords property to open a Recordset containing the ten most expensive titles in the Titles table.

Sub MaxRecordsX()

	Dim rstTemp As ADODB.Recordset
	Dim strCnn As String

	' Open recordset containing the 10 most expensive
	' titles in the Titles table.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	Set rstTemp = New ADODB.Recordset
	rstTemp.MaxRecords = 10
	rstTemp.Open "SELECT Title, Price FROM Titles " & _
		"ORDER BY Price DESC", strCnn

	' Display the contents of the recordset.
	Debug.Print "Top Ten Titles by Price:"

	With rstTemp
		Do While Not .EOF
			Debug.Print "    " & !Title & " - " & !Price
			.MoveNext
		Loop
		.Close
	End With

End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.