Why can't I declare a Variable of Type Database?

M

Mercy

I'm a newbie, and I'm working from a reference book.

The reference book has a fragment of code:

Dim db As Database
Set db = CurrentDb()

I tried putting this line into my VB code. But the
compiler keeps telling me "User-defined Type Not defined"

Why is it doing this to me?!

Thanks for any help,
Mercy
 
R

Rick Brandt

Mercy said:
I'm a newbie, and I'm working from a reference book.

The reference book has a fragment of code:

Dim db As Database
Set db = CurrentDb()

I tried putting this line into my VB code. But the
compiler keeps telling me "User-defined Type Not defined"

Why is it doing this to me?!

The book was written when everyone developing in Access was using DAO. Starting with
Access 2000 the default object library is ADO which doesn't have a database object.
To use that code you need to add a reference to DAO to your app and either remove the
reference to ADO entirely or get in the habit of prefixing all objects that exist in
both libraries (like DAO.Recordset instead of just Recordset).
 

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

Top