Compile error: User-defined type not defined

G

Guest

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

Private Sub Command5_Click()
Dim db As Database <<<----debugger 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
 
G

Graham Mandeno

"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.
 
G

Guest

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

Rgds.,
Walter


Graham Mandeno said:
"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

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

Private Sub Command5_Click()
Dim db As Database <<<----debugger 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
 

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