Compile error: User-defined type not defined

Compile error: User-defined type not defined

Post by Stape » Fri, 09 Mar 2007 02:29:01


Hi

This error popped up on this line of code:

Dim db as Database

Apart from the obvious self contradiction (defined .. not defined),
what can possibly be wrong with this statement. I have used it before
in numerous other projects?

Stapes
 
 
 

Compile error: User-defined type not defined

Post by storrbo » Fri, 09 Mar 2007 02:37:19


Depending on the version of Access you are using, you may need to
check the references and see if the DAO 3.xx, or ADO libraries are
selected and available. If both are available, you may need to
explicitly define which library to use.

Dim db As DAO.Database

 
 
 

Compile error: User-defined type not defined

Post by Douglas J. » Fri, 09 Mar 2007 02:47:48


The Database object only exists in DAO, not ADO. The fact that it's being
flagged as "not defined" implies that no reference has been set to DAO.

From within the VB Editor, select Tools | References. Scroll through the
list of available references until you find Microsoft.DAO 3.6 Object
Library, check it, and click on the OK button. If you've got references set
to both ADO and DAO, ensure you're properly disambiguating references to
objects that do exist in both models (such as Recordset: you need either As
DAO.Recordset or As ADODB.Recordset)

--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)
 
 
 

Compile error: User-defined type not defined

Post by Stape » Fri, 09 Mar 2007 02:49:59


What references, where ?

and see if the DAO 3.xx, or ADO libraries are
 
 
 

Compile error: User-defined type not defined

Post by Dirk Goldg » Fri, 09 Mar 2007 05:14:07


In the VB Editor, click Tools -> References..., then locate "Microsoft
DAO 3.6 Object Library" in the list and put a check-mark in the box next
to it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)