Export to XL code works in Access 2003 but not 2000

G

Guest

At the set rs statement I get a type mismatch error in Access 2000.
I have included a reference to Excel Library 9.0 . I can execute this using
a DAO connection in Access 2000, but I want to use ADO. What is causing this
error?


Option Compare Database
Option Explicit


Function ExportDetail()

Dim rs As Recordset
Dim intMaxCol As Integer
Dim intMaxRow As Integer
Dim objXLApp As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet

Error -> Set rs = CurrentDb.OpenRecordset("Order Details", _
dbOpenSnapshot)

intMaxCol = rs.Fields.Count
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
Set objXLApp = New Excel.Application
With objXLApp
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
With objSht
.Range(.Cells(2, 1), .Cells(intMaxRow, _
intMaxCol)).CopyFromRecordset rs



End With

End With


End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top