Dim as database Compile error

I

Ian

Hi,

I am trying to run the programe below but it keeps
saying:-

"compile error!

User-defined type not defined."

Can you please help me to get it to work.

ps it fails at the line :"Dim db1 As Database"


Dim db1 As Database
Dim rsTable As Recordset


Set db = CurrentDb

Set rsTable = db1.openrecordset("Zfiles")

rsTable.MoveFirst


Do While Not rsTable.EOF

Text1 = Text1 & rsTable!Order & ", "

rsTable.MoveNext

Loop

rsTable.Close
 
D

Douglas J. Steele

Let me guess (since you forgot to tell us). You're using Access 2000 or
Access 2002.

Database is a DAO object. By default, Access 2000 and 2002 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.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 rsTable as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rsTable 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

Top