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
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