Compile error: User-defined type not defined

  • Thread starter Thread starter Stapes
  • Start date Start date
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
 
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
 
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)
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top