Table-Type Recordset Example

This example opens a table-type Recordset, sets its Index property, and enumerates its records.

Sub dbOpenTableX()

    Dim dbsNorthwind As Database
    Dim rstEmployees As Recordset

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    ' dbOpenTable is default.
    Set rstEmployees = _
        dbsNorthwind.OpenRecordset("Employees")

    With rstEmployees
        Debug.Print "Table-type recordset: " & .Name

        ' Use predefined index.
        .Index = "LastName"
        Debug.Print "  Index = " & .Index

        ' Enumerate records.
        Do While Not .EOF
            Debug.Print "    " & !LastName & ", " & _
                !FirstName
            .MoveNext
        Loop

        .Close
    End With

    dbsNorthwind.Close

End Sub