Dim mydb as Database

G

Guest

Thanks for any help.
I inherited a large database, and only use a few of the tables, forms, and
queries in it, so I thought I would make a copy, and in the new version,
delete all the unnecessary stuff. Please don't laugh.
Well, anyway, when I run the macro on the form, I get this error:
Compile error:
User-defined type not defined
for the line:
Dim mydb As Database
But I can't see why this causes problems. This is a valid dim, right? I
looked at the code in the copy, but I couldn't find anywhere there where it
defines Database.
I am using MS Access VB 6.3. Any help appreciated.
Thanks.
 
F

fredg

Thanks for any help.
I inherited a large database, and only use a few of the tables, forms, and
queries in it, so I thought I would make a copy, and in the new version,
delete all the unnecessary stuff. Please don't laugh.
Well, anyway, when I run the macro on the form, I get this error:
Compile error:
User-defined type not defined
for the line:
Dim mydb As Database
But I can't see why this causes problems. This is a valid dim, right? I
looked at the code in the copy, but I couldn't find anywhere there where it
defines Database.
I am using MS Access VB 6.3. Any help appreciated.
Thanks.

What version of Access are you using?
Your Database probably has the ADO library set but not the DAO.
Make sure there is a reference set to the DAO library. Select the
highest version.
Then change the code to:

Dim Db as DAO.Database
 
G

Guest

Thanks Fred, I am using Access 2002.
Can you please tell me how to check if there is a reference set to the DAO
library?
Thank you
 
F

fredg

Thanks Fred, I am using Access 2002.
Can you please tell me how to check if there is a reference set to the DAO
library?
Thank you

Open any code window or press Ctrl + G.
Click on Tools + References
There will be several library references checked at the top of the
list.
See if there is a check next to Microsoft DAO Object 3.6 Library.
There probably is not one set.
Move down the list until you see Microsoft DAO Object 3.6 Library.
Place a check in the box.
Click OK

Change the code as previously suggested.
 
G

Guest

Thanks Fred!

fredg said:
Open any code window or press Ctrl + G.
Click on Tools + References
There will be several library references checked at the top of the
list.
See if there is a check next to Microsoft DAO Object 3.6 Library.
There probably is not one set.
Move down the list until you see Microsoft DAO Object 3.6 Library.
Place a check in the box.
Click OK

Change the code as previously suggested.
 

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