User-defined type not defined compile error (1 Viewer)

Zedster

Registered User.
Local time
Today, 08:37
Joined
Jul 2, 2019
Messages
169
I am returning to creating databases after a long absence. I am trying to re-use code from previous databases I have designed to save a time. Historically I have a function that checks that the access front end is able to connect to the SQL back end. I have copied this function across to the new database but I am getting a compile error "user-defined type not defined"

Code:
Dim cnn As ADODB.Connection
CheckSQLServerConnection = False

    Set cnn = New ADODB.Connection
    cnn.Open "Provider=SQLOLEDB;Server=localserver\databases;Database=Stores;Trusted_Connection=yes"

    If cnn.State = adStateOpen Then
        CheckSQLServerConnection = True
        cnn.Close
    End If

    Debug.Print CheckSQLServerConnection

The compiler highlights the third line above "Set cnn = New ADODB.Connection".

I am feeling quite a noob as I can't remember what causes this and how to get around it I am assuming it is associated with ADODB but I thought that was a standard Access term.

Any help appreciated.
 

moke123

AWF VIP
Local time
Today, 03:37
Joined
Jan 11, 2013
Messages
3,920
Did you set a reference to ADO?
 

Zedster

Registered User.
Local time
Today, 08:37
Joined
Jul 2, 2019
Messages
169
how do I do that? I suspected it may be down to references, so I got one of me previous database that ran, then from menu went tools > references and made sure all the same boxes were ticked. but that made no difference. The ones I have are:
Capture.PNG
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:37
Joined
May 21, 2018
Messages
8,529
The reference in question is Microsoft Active X Data Objects. Although, I have never seen Multi-dimensional before. I would unclick that one and search to another version of that reference.
 

Zedster

Registered User.
Local time
Today, 08:37
Joined
Jul 2, 2019
Messages
169
OK, got it, I had selected the wrong ActiveX data object (there were quite a lot).

This works:

Capture.PNG


Thanks for all the help.
 

Users who are viewing this thread

Top Bottom