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

  • Thread starter Thread starter Mercy
  • Start date Start date
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
 
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).
 
Back
Top