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?
posted by tdismukes to computers & internet (2 answers total) 2 users marked this as a favorite
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"
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.