Defining Database data type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code and get the error below. I tried removing DAO.
and tried ADODB.Database but I get the same error. Any help is appreciated.
I am using Access 2002 with an Access 2000 file format.

Option Compare Database
Option Explicit
Private Sub Command4_Click()
Dim db As New DAO.Database

Compile error:
User-defined type not defined
 
First - you have to make sure that a reference to DAO exists, it is required
in this case
second - you have to declare as:

Dim db As DAO.Database

and then either open database, ot create it using CreateDatabase method
 
How do I create a reference to DAO? I tried creating a connection, but that
did not seem to do it. Thanks
 
I figured out how to create a reference by using the VB window and selecting
Tools References MS DAO 3.6
 
Back
Top