I am trying to learn DAO and I can't figure out what I am doing wrong.
Code:
Option Compare Database
Option Explicit
Public Sub runQuery()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = OpenDatabase("DSN=VitaServer;UID=Username;PWD=Password;")
Set rs = db.OpenRecordset("Employees", dbOpenDynaset)
If Not rs.EOF Then rs.MoveFirst
Do Until rs.EOF
Debug.Print rs!FirstName
rs.MoveNext
Loop
db.Close
rs.Close
End Sub
Originally I had it set as
Code:
OpenDatabase("VitaServer", false, false, "UID=Username;PWD=Password")
but that was giving the same error code but a different message.
I have checked and my ODBC connection has "VitaServer" as the DSN.