Compile Error

  • Thread starter Thread starter Alison
  • Start date Start date
A

Alison

Hello Everyone,
I'm having a Compile Error: "User-defined type not
defined" when I use the following code in Access 2002.
Dim dbs As DAO.Database, rst As DAO.Recordset
The DAO.database is highlighted. This has happened to
other syntax that used to work, but now causes the same
error. I'm adding a record to a table when an entry in a
combo box field is Not-In-List.

Thanks for the help,
Alison
 
Sounds as though you haven't set a reference to DAO (it isn't set by default
in Access 2002, nor 2000)

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.x
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
 
Doug, Thanks so much for the information! I've
never "gotten" this part of programming. I can modify the
code, but not really create new. I'd love a reference to
a good learning tool if anyone has one.

Have a great day,
Alison
 

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
Table Append gets error 3420 4
Compile Error message! 2
Help with syntax error 1
Not in list event 10
Code error 11
Can someone check my code? 2
Access ConcatRelated() Function Not Working 0

Back
Top