Databases Reference
In-Depth Information
Debug.Print
' Move through dynaset-type recordset
Debug.Print "Dynaset-type recordset order:"
Set rsDyna = db.OpenRecordset("Books", dbOpenDynaset)
rsDyna.MoveFirst
Do While Not rsDyna.EOF
Debug.Print rsDyna!PubID & " / " & rsDyna!Title
rsDyna.MoveNext
Loop
rsTable.Close
rsDyna.Close
End Sub
It is worth remarking that, for a dynaset-type or snapshot-type recordset, or for a table-
type recordset for which the Index property has not been set, you cannot predict or rely
on the order of records in the recordset.
In this connection, two Recordset properties of particular use are AbsolutePosition and
PercentPosition, which give the ordinal position of the current record in a dynaset-type or
snapshot-type recordset and the percent position, respectively. Let us illustrate by
modifying Example 16-2, as shown in Example 16-3.
Example 16-3. The modified Recordset position example
Sub exaRecordsetPosition( )
Dim db As DATABASE
Dim rsDyna As Recordset
Dim strMsg As String
Set db = CurrentDb
Set rsDyna = db.OpenRecordset("Books", dbOpenDynaset)
' Move through recordset and display position
rsDyna.MoveFirst
Do While Not rsDyna.EOF
strMsg = rsDyna!PubID & " / " & rsDyna!Title
strMsg = strMsg & " / " & _
str$(rsDyna.AbsolutePosition)
strMsg = strMsg & " / " & _
Format$(rsDyna.PercentPosition, "##")
Debug.Print strMsg
rsDyna.MoveNext
Loop
rsDyna.Close
Search WWH ::




Custom Search