Where did my DAO go?
March 26, 2012 1:49 PM   Subscribe

Microsoft Access programming problem - what do I have to configure in my database to make use of the DAO object?

I'm working through a tutorial book on programming Access applications and at the same time applying lessons from the book to a real-world project. The book has a CD with sample databases which can be altered in the course of the exercises for each chapter.

The following is a bit of code from Chapter 8 of the book, which I typed in and which works perfectly in the supplied Chapter 8 database:

Private Sub ShowRecord_Click()
'Find the selected record, then close thedialog box

Dim rst As DAO.Recordset

'Store the recordset for the Subscribers form
Set rst = Forms!Subscribers.RecordsetClone

'Locate the record for the selected subscriber
rst.FindFirst "SubscriberID = " & List0

'Set the form's Bookmark property to move to the record
Forms!Subscribers.Bookmark = rst.Bookmark
'Close the dialog box
DoCmd.Close acForm, "GoToRecordDialog"

End Sub

I've tried copying this code over to my real-world project, where it should serve exactly the same function (except that I've changed the names of the forms as appropriate). It won't compile, because in my application, Access does not seem to recognize the DAO object in the line: Dim rst As DAO.Recordset.

In fact, when I type "Dim rst As " and then check the available datatypes in the intellisense list, my database is giving me a reduced set of options compared to the Chapter 8 database from the book.

In the database from the book the list contains ... DAO, DataAccess Page, DataAccessPages, Database, Databases ... etc.
In my database the available list contains DataAccessPage and DataAccessPages, but not DAO, Database or Databases.

I'm working in Access 2002, which is the same as the book covers. There must be some configuration option at the database level which is set for the database in the book to give access to the DAO object but is not set for my database. However I haven't been able to find any clues either in the Access help files or with Google.

Thanks in advance for any advice.
posted by tdismukes to Computers & Internet (2 answers total) 2 users marked this as a favorite
 
Best answer: You need to check the box by "Microsoft DAO 3.6 Object Library" in the References interface, which you get to from the VBA interface, under the "Tools" menu.

It's normally enabled by default, but I guess that may have changed in the newer versions. If It is checked, and says "MISSING", then you should probably reinstall Office.
posted by thelonius at 2:42 PM on March 26, 2012 [1 favorite]


Response by poster: That did it!

Thanks, thelonius. I knew it had to be something like that, but I couldn't find the right menu.
posted by tdismukes at 4:40 PM on March 26, 2012


« Older Delete a file that isn't there (Mac file problem)   |   Help me buy a custom gaming PC Newer »
This thread is closed to new comments.