Dim Statements

  • Thread starter Thread starter Bob Rice
  • Start date Start date
B

Bob Rice

Dim ThisDB As Database

or

Dim ThisTable As TableDef
produces the compile error: User-defined type not defined

Anyone know what I do to correct this?

Thanks.
 
It would have helped if you mentioned details such as what version of Access
you're using...

I'm going to assume you're using Access 2000 or 2002. Database and TableDef
are DAO objects, and by default, Access 2000 and 2002 both use ADO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.1
Library

If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rsCurr as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsCurr As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and 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

Similar Threads

dao and ado 2
VBA CODE HELP! 0
Access97: TableDef not returnable??? 2
Access ConcatRelated() Function Not Working 0
look up 5
User-Defined type not defined 6
error in background color change code 2
Compile Error 5

Back
Top