+ Reply to Thread
Results 1 to 4 of 4

Error message: "Compile error. User-defined type not defined"

  1. #1
    Registered User
    Join Date
    08-27-2007
    Posts
    48

    Error message: "Compile error. User-defined type not defined"

    Hi,
    I am trying to get an Excel sheet to read/write to an Access DB. My code starts as shown below.
    When running it, I get the error: "Compile error. User-defined type not defined" - it crashes on the "Dim cnn As ADODB.Connection" line. I also notice that while String and Integer are syntax highlighted in blue, Range, ADODB.Connection and ADODB.Recordset remain black. I am guessing that my VB doesn't know how to interpret the ADODB commands.
    In tools-references, Microsoft DAO 2.5/3.51 compatability library is selected.

    Any thoughts on how to solve this would be welcome.

    Lotte

    Please Login or Register  to view this content.
    ...
    Last edited by dominicb; 09-18-2007 at 03:50 AM.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi Lotte

    Since you are attempting to use ADO and not DAO (be sure you are actually trying to use ADO to make the connection) then you need to reference the Microsoft ActiveX Data Objects 2.X library via Tools>References rather than a DAO library.

    Richard

  3. #3
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    I think you need to deselect, in tools-references, "Microsoft DAO 2.5/3.51 object library" and to select "Microsoft Activex Data Objects 2.x Library" because you use ADO instructions in your code that are different from DAO instructions.

    Regards,
    Antonio

  4. #4
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    Antonio and Richard,
    Thank you!!!
    Lotte

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1