Access 2002: Dim x As Database, Type Not defined

M

Muhib

Hi,

In access 2002 I converted an old Access 97 Database having an ODBC
connection
and it works OK. Created a new databased in Access 2002 on defining the
Database
type as:

Dim xDB as Database

I get the compiler error: User-Defined Type not defined?

Any comments appreciated.
 
R

Randy Harris

Muhib said:
Hi,

In access 2002 I converted an old Access 97 Database having an ODBC
connection
and it works OK. Created a new databased in Access 2002 on defining the
Database
type as:

Dim xDB as Database

I get the compiler error: User-Defined Type not defined?

Any comments appreciated.

In A2K2, a reference to DAO is not enabled by default. Open your code
module, select Tools->References and select DAO. You might wish to unselect
ADO, to be certain that there is no conflict. That will stop the error you
are getting.

HTH,
Randy
 
M

Muhib

Thanks Randy, it did work, I selected Microsoft DAO 3.6 Library

Dim xDB As Database 'Variable to hold Database object
Dim xTable As Recordset 'Variable to hold Table Object
Set xDB = Workspace.OpenDatabase("myDB.MDB")

I get Erorr: Object Required.

Regards.

Muhib
 
D

Douglas J. Steele

Since you can't be sure what the current directory is, try using a complete
path to myDB.MDB, not just the file name.

Also, assuming you didn't remove the reference to ADO when you added the DAO
reference, you'll want to "disambiguate" your declaration for the Recordset,
as Recordset is an object in both the ADO and DAO models, and, since ADO is
higher in the sequence of references, what you've got will yield an ADO
recordset. Try

Dim xTable As DAO.Recordset

(if you wanted to guarantee that you'd get an ADO recordset, you'd use Dim
xTable As ADODB.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