
VBA Doesn't recognize DAO.RecordSet
Except that it's Microsoft DAO 3.6 Object Library for Access 2000 and 2002.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
Unlike earlier versions, Access 2000 and later don't reference the DAO
library. To change this, from the code window, choose Tools, then
References, and in the References dialog that appears, check the box beside
the entry for "Microsoft DAO 3.51 Object Library".
I created a new database and a new form. I used DAO code in the new form
just as I did in another database. For some reason it doesn't work in the
new database. The code is:
Private Sub Command0_Click()
Dim rList As dao.Recordset, rQuery As dao.Recordset
Dim dbs As Database
Set dbs = CurrentDb
sql = "select * from [Sample Data]"
Set rList = dbs.OpenRecordset(sql)
sql = "Select * from [Excel Test Query]"
Set rQuery = dbs.OpenRecordset(sql)
rList.MoveFirst
Do Until rstMBC.EOF
MsgBox rList!table + " " + rList![field name]
rList.MoveNext
Loop
MsgBox "Done"
End Sub
I know this code works in the other database. I believe I am overlooking
some setup. Could you help?
Thanks,
Elliot