Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

TechKnowledge Content

Issue


Error - 'Compile Error: User-defined type not defined' occurs when attempting to compile code.


Note -I am using the ADO with VBA examplesdownloaded from the web. Thefirst three lines of the code are copied in directly from the document as:


Dim cn As New ADODB.Connection

Dim rst As New ADODB.Recordset

Dim cmd As New ADODB.Command


Resolution


Mark a reference to aMicrosoft Active X Data Object Library in the VBA editor.


1. Open up the VBA editor and go to Tools | References.


2. Scroll down until you see the Microsoft Active X Data Object Library.


3. If you have multiple versions,use the latest version. The versionswill correspond to the versions of MDAC. The only time you would not want to use the latest version is if you are distributing the Project to a machine that hasan older version on it. So if the machinesyou are distributing to only have MDAC 2.6 installed, and you have MDAC 2.7,check the reference to version 2.6 of the Microsoft Active X Data Object Library to ensure that the Project will work on the machines you are distributing it to.

This article was TechKnowledge Document ID:29167

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×