Help --> Compile Error - User defined type not defined

F

FatMan

Hello all:
I am wondering if anyone can help me the the follownig error:

Compile Error
User - defined type not defined

I get his error when I run my program and it stops on the following line of
code....

Dim Db As DAO.Database

The line of code is part of a procedure used to delete a table from a
different database. The full code is listsed below.

If anyone could please let me know what I am doing wrong I would greatly
appreciated it. Database and Code was created in Access 2000.

Thanks,
FatMan


Full Code....

Public Sub DeleteForeignData()

On Error GoTo Err_Handler
Dim Db As DAO.Database
Set Db = OpenDatabase("C:\Program Files\OCR Canada\OCRInv.mdb")

Db.Execute "Delete * from CollectedBatchData", dbFailOnError


Exit_Sub:
Db.Close
Set Db = Nothing
Exit Sub
Err_Handler:
MsgBox "Error #: " & Err.Number & " " & Err.Description
Resume Exit_Sub
End Sub
 
F

fredg

Hello all:
I am wondering if anyone can help me the the follownig error:

Compile Error
User - defined type not defined

I get his error when I run my program and it stops on the following line of
code....

Dim Db As DAO.Database

The line of code is part of a procedure used to delete a table from a
different database. The full code is listsed below.

If anyone could please let me know what I am doing wrong I would greatly
appreciated it. Database and Code was created in Access 2000.

Thanks,
FatMan

Full Code....

Public Sub DeleteForeignData()

On Error GoTo Err_Handler
Dim Db As DAO.Database
Set Db = OpenDatabase("C:\Program Files\OCR Canada\OCRInv.mdb")

Db.Execute "Delete * from CollectedBatchData", dbFailOnError


Exit_Sub:
Db.Close
Set Db = Nothing
Exit Sub
Err_Handler:
MsgBox "Error #: " & Err.Number & " " & Err.Description
Resume Exit_Sub
End Sub

Sounds like a missing reference (or no reference to the DAO library).

Open any module in Design view (or click Ctrl + G).
On the Tools menu, click References.
Click to clear the check box for the type library or object library
marked as "Missing:."
Make sure there is a reference set to the Microsoft DAO 3.6 object
library!

An alternative to removing the reference is to restore the referenced
file to the path specified in the References dialog box. If the
referenced file is in a new location, clear the "Missing:" reference
and create a new reference to the file in its new folder.

For even more information, see
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html
 
F

FatMan

Fred:
Thanks. You were bang on.

FatMan

fredg said:
Sounds like a missing reference (or no reference to the DAO library).

Open any module in Design view (or click Ctrl + G).
On the Tools menu, click References.
Click to clear the check box for the type library or object library
marked as "Missing:."
Make sure there is a reference set to the Microsoft DAO 3.6 object
library!

An alternative to removing the reference is to restore the referenced
file to the path specified in the References dialog box. If the
referenced file is in a new location, clear the "Missing:" reference
and create a new reference to the file in its new folder.

For even more information, see
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html
 

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