UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Can't Add Dao Reference    
 
   
doctor9
post Apr 17 2012, 02:00 PM
Post #1

UtterAccess VIP
Posts: 9,430
From: Wisconsin



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
Go to the top of the page
 
+
theDBguy
post Apr 17 2012, 02:17 PM
Post #2

Access Wiki and Forums Moderator
Posts: 48,599
From: SoCal, USA



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... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
doctor9
post Apr 17 2012, 02:19 PM
Post #3

UtterAccess VIP
Posts: 9,430
From: Wisconsin



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
Go to the top of the page
 
+
doctor9
post Apr 17 2012, 03:02 PM
Post #4

UtterAccess VIP
Posts: 9,430
From: Wisconsin



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
Go to the top of the page
 
+
theDBguy
post Apr 17 2012, 03:17 PM
Post #5

Access Wiki and Forums Moderator
Posts: 48,599
From: SoCal, USA



Hi Dennis,

Glad to hear you got it sorted out.

Cheers (IMG:style_emoticons/default/cheers.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 06:47 AM