Referece set to ADO 2.8 but declaring ADODB causes error "User-Defined type not defined.

Posted on 2006-03-28
Last Modified: 2008-02-01
I have set a reference to msador15.dll and started to write a function as follows.

    Dim cnn As ADODB.Connection
    Set cnn = New ADOR.Connection

I then tried to compile this to check I was on the right path and I get the message "User-Defined Type not defined"

I have searched MSDN, here and some other forums but am still lost. Most examples suggest setting a reference to ADOn.n and thats what I have done.

I have tried referencing msadomd.dll and the ADO ext. 2.7 for dll and secuiity niether have helped me out.

Am I missing a simple trick or am I heading along the wrong path in the wrong woods?

Many thanks

Dan T
Question by:DanT4Syncro
    LVL 92

    Expert Comment

    by:Patrick Matthews
    Hi DanT4Syncro,
    > Set cnn = New ADOR.Connection

    Don't you mean:

        Set cnn = New ADODB.Connection




    Author Comment

    Hi Patrick,

    Many thanks for your reply and making me realise I made a mistake typing that out.

    This is what I have that causes the error when I try to compile

        Dim cnn As ADODB.Recordset
        Set cnn = New ADODB.Recordset

    The first line is highlighted from cnn onwards.

    Also to clarify I am using Access 2003  


    Dan T

    Author Comment

    Some additional information

    When I set the reference to the msador15.dll the reference is titled. "Microsoft ActiveX Data Objects RecordSet 2.7 Library". If I return to the references again the msador15.dll reference now shows as being "Microsoft ActiveX Data Objects RecordSet 2.8 Library"

    Does this have any significance?
    LVL 84
    With the reference you've got set, your syntax would be this:

    Dim cnn As ADOR.Recordset

    You should instead NOT have a reference to the "Microsoft ActiveX Data Objects RecordSet 2.7 Library" (unless you have a need for it), but instead set a reference to the "Microsoft Activex DataObjects 2.x Library" and do away with the Recordset 2.7 Library reference ...

    Author Comment

    Thanks for the reply.

    The reference you suggest is the reference I originally started out looking for. However in my list of references I can see the following:

    "Microsoft ActiveX Data Objects RecordSet 2.7 Library"                          File name "msador15.dll"
    "Microsoft ActiveX Data Objects (Multi-dimensional) 2.7 Library"             File name "msadomd.dll"
    "Microsoft ADO ext. 2.7 for DDL and security"                                        File name "MSADOX.dll"

    I have trawled through all the references that start with an "M" and there isn't a reference for

    "Microsoft Activex DataObjects 2.x Library"

    Could it be I need to browse and add the correct reference? If so is there a filename I should be looking for?

    Many thanks again

    LVL 84

    Accepted Solution

    No, if you're not showing any of the "Microsoft ActiveX Data Objects xx Library" references, you may very well have some problems with MDAC, and you cannot simply reference a single file ... MDAC is very complex (and HUGE) and you must do a reinstall if you have troubles..

    FWIW: I'm showing about 6 different versions of this library, as well as the other 3 references you mention.

    Perhaps download the ComponentChecker from MS and see exactly what version of MDAC you're running:

    Your version of MDAC depends on many different things, but the CC tool should be able to determine exactly which version you're running, and should be able to detect problems with your MDAC install.

    Author Comment

    Many thanks for you reply again. I shall do as you suggest and let you know what the score is.


    LVL 27

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

    I will leave the following recommendation for this question in the Cleanup topic area:
        Accept: LSMConsulting {http:#16328882}

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now