Full Version: Can't Add Dao Reference
UtterAccess Discussion Forums > Microsoft® Access > Access Modules
doctor9
In this thread I decided to download the original QuizMaker demo, and convert the 2003 version to 2010. I created a new, blank database in Access 2010, then imported all of the objects.

One form ("frmTakeQuiz") uses DAO recordsets in it's VBA code. Specifically, the following lines were causing an error because there was a missing reference:

Dim dbs As Database
Set dbs = CurrentDB

The actual error (while highlighting "dbs As Database") was:
Compile error:
Expected user-defined type, not project


I ASSUMED that this would be fixed by adding a DAO reference. When I went to the References dialog box, the following list of DAO references was available:
Microsoft DAO 2.5/3.51 Compatibility Library
Microsoft DAO 3.51 Object Library
Microsoft DAO 3.6 Object Library

NONE of them worked. In fact, when I tried to add ANY of them, I got the following error message:

Name conflicts with existing module, project, or object library

For the record, here are the references that were checked in my new, blank database:
Visual Basic For Applications
Microsoft Access 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Access database engine Object Library

Does DAO conflict with one of these? If so, does that mean there's no need to add a reference to DAO any more?

The only reference in the 2003 database that isn't in the 2010 database is:
Microsoft ActiveX Data Objects 2.1 Library
(well, that and Microsoft DAO 3.6 Object Library)

Adding the ActiveX reference did not prevent the error. I'm guessing that reference was left over from when I was trying to use an ActiveX control, but later changed my mind, and doesn't really do anything to make the 2003 database work. (I just removed the reference from the 2003 database and tried everything I could - no problems.)

I'd like to know which reference to add to get "Dim dbs as Database" to work - if only for curiosity's sake. I bypassed it by hard-coding "CurrentDB" wherever I was using "dbs", but someday I may need to define two different databases.

Thanks,

Dennis
theDBguy
Hi Dennis,

I believe in 2010, the DAO library is already included in the reference:

Microsoft Office 14.0 Access database engine Object Library

So, you can't add any other DAO library but your code should still work.

Just my 2 cents... 2cents.gif
doctor9
DBGuy,

The DAO portion DOES work. However, I can't use:

Dim dbs as Database

Apparently it's not DAO. I'm trying to figure out what it is. Or maybe what new syntax I should use to accomplish the same thing in Access 2010.

Dennis
doctor9
AHA!

If I change this:

Dim dbs as Database

To this:

Dim dbs as DAO.Database

It works just fine. Apparently "Database" is not explicit.

Dennis
theDBguy
Hi Dennis,

Glad to hear you got it sorted out.

Cheers cheers.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.