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
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