473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
4 21503
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Tom Chidwick | last post by:
Hello, I've custom-built a fairly extensive object model that is designed to run in the background and control the opening and closing of related forms. The whole thing kicks-off with an...
3
by: Bart Lateur | last post by:
For some reason, "Database" isn't recognised by Access as a built-in/predefined type, in Access' own VBA. Whenever I try to compile a line like Dim db as Database I get the complaint that...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
12
by: pmclinn | last post by:
What is the difference between these declarations: Dim strMyData() as string and Dim strMyData as string() -Peter
14
by: Geoff Jones | last post by:
Hi I'm trying to use a class that I've written in a form. Unfortunately, when I write something like: Public x As New myClass I get the compile time error: "Type Expected". Indeed, the...
3
by: Tomdhu | last post by:
As a Newbie I've picked up a heap of tips and tricks from this NG but I have been battling to get the current user's Netwok Login ID recorded on a form at the time a new record is created or...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
23
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the...
11
by: kimiraikkonen | last post by:
Hello, I'm very new to C# and just installed VC# 2005 express edition and i have VB 2005 express installed previously. But i saw a thing which may be called as a "Visual C# 2005 express" bug? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.