Forward-Only–Type Recordset Example

This example opens a forward-only-type Recordset, demonstrates its read-only characteristics, and steps through the Recordset with the MoveNext method.

Sub dbOpenForwardOnlyX()

   Dim dbsNorthwind As Database
   Dim rstEmployees As Recordset
   Dim fldLoop As Field

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
   ' Open a forward-only-type Recordset object. Only the 
   ' MoveNext and Move methods may be used to navigate 
   ' through the recordset.
   Set rstEmployees = _
      dbsNorthwind.OpenRecordset("Employees", _
      dbOpenForwardOnly)

   With rstEmployees
      Debug.Print "Forward-only-type recordset: " & _
         .Name & ", Updatable = " & .Updatable

      Debug.Print "  Field - DataUpdatable"
      ' Enumerate Fields collection, printing the Name and 
      ' DataUpdatable properties of each Field object.
      For Each fldLoop In .Fields
         Debug.Print "    " & _
            fldLoop.Name & " - " & fldLoop.DataUpdatable
      Next fldLoop

      Debug.Print "  Data"
      ' Enumerate the recordset.
      Do While Not .EOF
         Debug.Print "    " & !FirstName & " " & _
            !LastName
         .MoveNext
      Loop

      .Close
   End With

   dbsNorthwind.Close

End Sub