When recompiling a database or migrating a database you get the following error:


Compile Error - User-defined type not defined, (see screen shot below)



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.



Links

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_access-mso_other/compile-error-user-defined-type-not-defined-on-dim/d21efe0f-987d-4aaa-a3f7-5bcf677158b4