Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Connection Error

Status
Not open for further replies.
May 14, 2004
108
US
I have an Excel spreadsheet that I need to copy some of the data into Access. I found some code in this forum to copy it in, and it works fine on my machine.

When I copy the macro to another machine and get a Compile Error on the line 'Dim cn As ADODB.Connection'. The exact error is "Compile error: User-defined type not defined". I verified the references are the same.

Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=J:\Guest_Incidents.mdb;"
Set rs = New ADODB.Recordset
rs.Open "GuestIncident", cn, adOpenKeyset, adLockOptimistic, adCmdTable


What else should I check to get the code to compile?

Thanks
 
You have to reference an existing Microsoft ActiveX Data Objects Library.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top