Compile error - user defined type not defined, on Dim dbs as Database

I have a database which has started showing a compile error on the standard Microsoft switchboard - user defined type not defined, on line Dim dbs as Database. All other databases still run OK. Help with this would be appreciated thanks.  Ian
 

Question Info


Last updated November 15, 2018 Views 29,710 Applies to:
Answer

Make sure the Data Access Objects library (DAO) is checked in the Tools - References list in the VBA Editor's menu/ribbon.  (The specific name of the library can be different in different versions of Access)

 

Also look at the ActiveX Data Objects library (ADO) in the list and if you do not have a good reason for using it, uncheck it so it doesn't weigh your app down with unused stuff.  If you do have a good reason for using both libraries, then you should declare objects that exist in both libraries with their library name:

   Dim rs As DAO.recordset

or

   Dim rs As ADODB.Recordset

depending on which one you are using in in a procedure.

 

The Database object only exists in the DAO library, so it is not absolutely necessary to qualify it in declarations, but it's a good idea if for no other reason than as a reminder of which library it is in.

23 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Answer

Try....

Dim dbs as DAO.Database

 

Also, you'll want to check your References...

http://www.access-diva.com/d5.html

...as there might be one that is marked *MISSING*.

Gina Whipp
Microsoft MVP (Access 2010-2015)
https://www.access-diva.com/tips.html

13 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.