By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

anybody know why "Dim db As Database" won't compile????

P: n/a
It compiles fine in one of my ms2002 databases, but on another db (I
inherited from somebody else), I get this compile error: "User-defined type
not defined"

Is something turned off in this second db or something? Thanks much
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The reference to the Microsoft DAO 3.6 Library is not, by default, set in
Access 2000 and later versions -- the ADO reference is set by default. So
what you most likely need to do is open a module, and in the module window's
menu, Tools | References, find that library, check it, _and_ just to be on
the safe side, move it above the ADO reference in the list. And, make it a
practice to qualify references to DAO objects as in

Dim rs as DAO.Recordset
Dim td as DAO.TableDef

because some object names are both in DAO and ADO and you should keep them
clearly separate so you, or someone else, doesn't get confused reading the
code later. "Database" is not an object in the ADO library, so it didn't
confuse it, it just didn't know what it is without the DAO library being
referenced.

Larry Linson
Microsoft Access MVP

"Monte" <j.*****@earthlink.net> wrote in message
news:RI*****************@newsread4.news.pas.earthl ink.net...
It compiles fine in one of my ms2002 databases, but on another db (I
inherited from somebody else), I get this compile error: "User-defined type not defined"

Is something turned off in this second db or something? Thanks much

Nov 12 '05 #2

P: n/a
Make sure you have the right references in this new database. Meaning DAO
and/or ADO. And then to get rid of any amiguities define it as DAO.Database
or ADODB.Database...
"Monte" <j.*****@earthlink.net> wrote in message
news:RI*****************@newsread4.news.pas.earthl ink.net...
It compiles fine in one of my ms2002 databases, but on another db (I
inherited from somebody else), I get this compile error: "User-defined type not defined"

Is something turned off in this second db or something? Thanks much

Nov 12 '05 #3

P: n/a
Thanks very much, Bill and Larry! It would have taken me 100 years to
discover that...
"Bill" <zi*****@hotmail.com> wrote in message
news:vp************@corp.supernews.com...
Make sure you have the right references in this new database. Meaning DAO
and/or ADO. And then to get rid of any amiguities define it as DAO.Database or ADODB.Database...
"Monte" <j.*****@earthlink.net> wrote in message
news:RI*****************@newsread4.news.pas.earthl ink.net...
It compiles fine in one of my ms2002 databases, but on another db (I
inherited from somebody else), I get this compile error: "User-defined

type
not defined"

Is something turned off in this second db or something? Thanks much


Nov 12 '05 #4

P: n/a
Bill wrote:
Make sure you have the right references in this new database. Meaning DAO
and/or ADO. And then to get rid of any amiguities define it as DAO.Database
or ADODB.Database...


FWIW.. ADO doesn't have a Database property/method. DAO does. The most common
ambiguity is in the .Recordset object that both ADO and DAO have so its best
to ensure you've defined your Recordsets such as:

Dim rst As DAO.Recordset

to clearly document your choice of object model. Nothing prevents you from
using both DAO and ADO in your code but you will need to be specific about
which one you are defining. Without the prefix you'll get a recordset of
the type of the Object Model that appears higher in the References list.

--
'-------------------------------
' John Mishefske
'-------------------------------

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.