473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21546
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.*****@earthl ink.net> wrote in message
news:RI******** *********@newsr ead4.news.pas.e arthlink.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.*****@earthl ink.net> wrote in message
news:RI******** *********@newsr ead4.news.pas.e arthlink.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*****@hotmai l.com> wrote in message
news:vp******** ****@corp.super news.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.*****@earthl ink.net> wrote in message
news:RI******** *********@newsr ead4.news.pas.e arthlink.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
9441
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 AutoExec macro at startup, using a RunCode action that calls a global function and the rest works great. Pretty good stuff - flies like an eagle, when it works.
3
16995
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 that user defined type ("database") isn't defined. This happens both in Access 97 (on Win98) and in Access 2000 (on XP). I seem to recall this used to work on Access 2. For the rest, Access works normally.
3
3184
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 missing from the code? Thanks - Jon Private Sub MakeParentTable() ' Create a new DataTable. Dim myDataTable As Datatable = New Datatable("ParentTable")
12
1265
by: pmclinn | last post by:
What is the difference between these declarations: Dim strMyData() as string and Dim strMyData as string() -Peter
14
14170
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 "squiggly" blue line does appear under myClass so I half expeced it. However, I had written
3
3591
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 modified. I haven't implemented Access security, and want their Network Login ID. The network is running W2K server and all users have unique login ID's. I run A2K and I've found Dev Ashish's code at http://www.mvps.org/access/api/api0008.htm . I...
4
3317
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 class1 public sub showimg() Dim Response As HttpResponse = HttpContext.Current.Response Dim theImage As New object
23
5090
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 solution, and was greeted with the following error: ======================================================================== It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error...
11
2025
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? For example, in VB 2005 express while i was coding, if there's a coding error, errors are displayed in error list below the screen immediately during coding and before starting debugging. But in VC# 2005 express, if there's a coding error,...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.