Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error 'Compile Error: User-defined type not defined' Attempting to Compile Code


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

↑ Back to the top


Keywords: kbmbspartner, kbmbsmigrate, kb

↑ Back to the top

Article Info
Article ID : 858611
Revision : 1
Created on : 1/7/2017
Published on : 7/13/2012
Exists online : False
Views : 86