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