Compile error: User-defined type not defined

Compile error: User-defined type not defined

Post by UklQ » Tue, 10 May 2005 05:57:05


I am getting a compile error... Can someone pls tell me what I am doing
wrong...

Private Sub Command5_Click()
Dim db As Database <<<----de *** highlights this yellow
Dim rctMakeAdd As Recordset

'*** Create a pointer to the database and a pointer to the table ***
Set db = CurrentDb()
Set rctMakeAdd = db.OpenRecordset("tblMake", dbOpenTable)

' ****Validate the Date field***
If IsNull(make) Or Len(make) = 0 Then
MsgBox "Please Enter a Make"
make.SetFocus
rctMakeAdd.Close
db.Close
Exit Sub
End If
 
 
 

Compile error: User-defined type not defined

Post by Graham Man » Tue, 10 May 2005 06:22:04

"Database" is an object which is declared in the Data Access Objects (DAO)
object library.

By default, Access 2000 gives new databases a reference to the ActiveX Data
Objects (ADO) library, and omits a reference to the DAO library. (They have
reversed this change in later versions, thank goodness!)

From the code window, go to Tools->References. Find and check:
Microsoft DAO 3.x Object Library
(where "3.x" is the highest version you can see - probably 3.6)

If you are NOT using any ADO code anywhere in your database, you can uncheck
the reference to:
Microsoft ActiveX Data Objects 2.x Library

It's a good idea to include an explicit "DAO." in your declarations, to
make it clear which object model you are using. For example:
Dim db as DAO.Database
Dim rs as DAO.Recordset

This is not so essential for "Database", but both libraries have a
"Recordset", so the ambiguity can become a problem.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

 
 
 

Compile error: User-defined type not defined

Post by UklQ » Tue, 10 May 2005 14:05:43

That did it!!!! Thank you very much Graham!!!

Rgds.,
Walter