Reading a Persisted Recordset : Recordset to File « Access « VBA / Excel / Access / Word






Reading a Persisted Recordset

 
Sub ReadPersistedRecordset()
    Dim strFileName As String

    strFileName = "c:\test.txt"

    If Len(Dir(strFileName)) = 0 Then
        msgBox "File Not Found"
        Exit Sub
    End If

    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset
    rst.ActiveConnection = CurrentProject.Connection
    rst.CursorType = adOpenStatic
    rst.LockType = adLockOptimistic

    rst.Open Source:=strFileName, _
        Options:=adCmdFile

    Do Until rst.EOF
        Debug.Print rst("EmployeeID")
        rst.MoveNext
    Loop

    rst.Close
    Set rst = Nothing

End Sub

 








Related examples in the same category

1.Save Recordset to a file