View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
oscar.c.marin[_2_] oscar.c.marin[_2_] is offline
external usenet poster
 
Posts: 12
Default Error on connection to recordset

Office 2003
I'm trying to obtain information from a query in Access from a Sub in
Excel-VBA. The code follows. I receive an error message indicating that the
recordset cannot be opened.

Dim rngEmployees As Range
Set rngEmployees = vacations.Range("vacations_names").Offset(1, 0)
Dim rngEmpLastName As Range
Set rngEmpLastName =
vacations.Range("vacations_names").Offset(1, 1)
Dim intColIndex As Integer
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source" & _
"=C:\Documents and Settings\oscar\Mis Documentos\aaa-oacm\" & _
"aaa-tech_projects\planillas_project\nomina.mdb;"
rs.Open "tblEmployees, cn"
rngEmployees.CopyFromRecordset rs

Thank you in advance.

Oscar