I get a "User-defined type not defined" error when I execute the below code, and the
"objCon As ADODB.Connection"
is highlighted on the first line. I am trying to set a connection from Excel to Access via VBA code. Thank you for any advice!
Private objCon As ADODB.Connection Private rstRec As ADODB.Recordset Private strQry Sub Connect() Dim strConn As String Set objCon = New ADODB.Connection objCon.Mode = adModeReadWrite If objCon.State = adStateClosed Then strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "C:\DB\Db.accdb;Persist Security Info=False;" objCon.ConnectionString = strConn objCon.Open End If End Sub
share|edit|close|delete|flagabove the comments? thedeleteIf not I can make it as an answer..