Compile error: User-defined type not defined

S

Stapes

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
 
S

storrboy

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


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
 
D

Douglas J. Steele

storrboy said:
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

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)
 
S

Stapes

Depending on the version of Access you are using, you may need to
check the references

What references, where ?

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

Dirk Goldgar

Stapes said:
What references, where ?

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.
 
Top