Open dBase file and query data
Sub Open_dBase_DSNLess()
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Set conn = New ADODB.Connection
conn.Open "DRIVER={Microsoft dBase Driver (*.dbf)};" & "DBQ=" & CurrentProject.Path & "\"
Debug.Print conn.ConnectionString
Set rst = New ADODB.Recordset
rst.Open "Select * From Customer.dbf", conn, adOpenStatic, adLockReadOnly, adCmdText
Do Until rst.EOF
Debug.Print rst.Fields(1).Value
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
conn.Close
Set conn = Nothing
End Sub
Related examples in the same category