Read record in recordset by referening the field name with '!'
Public Sub Loops()
Dim con As ADODB.Connection
Dim rs As New ADODB.Recordset
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\store.mdb;"
rs.CursorLocation = adUseServer
rs.Open "SELECT * FROM Employees", con, adOpenStatic, adLockOptimistic
Do While Not rs.EOF
Dim strName As String
Debug.Print rs!txtCustFirstName & " " & rs!txtCustLastName
rs.MoveNext
Loop
Debug.Print rs.RecordCount & " records: "
Set rs = Nothing
Set con = Nothing
End Sub
Related examples in the same category