Excel 2003 Connection error message "User-defined type not defined"

From Excel 2003 need to connect to Access database.  
This line of VB code in the Visual Basic Editor    
Dim cnn As ADODB.Connection  
always gives error message : "User-defined type not defined"



Dim cnn As ADODB.Connection
Set cnn = New adodb.Connection
   With cnn
      .ConnectionTimeout = 500
      .Provider = "Microsoft.Jet.OLEDB.4.0"
      .ConnectionString = "Data Source=" & strPathToDB & ";"
      .Open
      .CommandTimeout = 500
   End With

Open in new window

OceanStarsAsked:
Who is Participating?
 
spattewarConnect With a Mentor Commented:
This means that you have not referened the ADODB library.

In your VBA editor. goto tools->references and add reference to Microsoft ActiveX Data Objects library

$wapnil
0
 
OceanStarsAuthor Commented:
Thank you.  I just found the answer myself.  You are fast!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.