T
tmort
It looks like I only have ADO in one place. This is the code:
Public Function ExportToExcel(strqrySQL As String)
Dim rst As ADODB.Recordset
Dim intCount As Integer
' Create the Excel object
Set mobjXl = New Excel.Application
Set rst = New ADODB.Recordset
' Fetch the recordset
With rst
.ActiveConnection = CurrentProject.Connection.ConnectionString
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.MaxRecords = 65000 ' Approx max number of rows Excel can handle
.Open strqrySQL
End With
With mobjXl
' Add a workbook and turn off Excel updates
.ScreenUpdating = True
.Visible = False
.Workbooks.Add
.DisplayAlerts = False
.Columns.ColumnWidth = 17.5
' Add the column headers
For intCount = 0 To rst.Fields.Count - 1
.Cells(1, intCount + 1).Value = rst.Fields(intCount).name
Next intCount
' Dump the recordset to Excel
.Range("A2").CopyFromRecordset rst
.Visible = True
End With
mobjXl.ActiveSheet.Columns("A:J").HorizontalAlignment = Excel.xlCenter
mobjXl.Range("A1").Select
' Columns("A:J").Select
' With Selection
' .HorizontalAlignment = xlCenter
' End With
' Range("A1").Select
' Add your error handler
******************************************************
Do I just change:
Dim rst As ADODB.Recordset to
Dim rst As DAO.Recordset
and
Set rst = New ADODB.Recordset to
Set rst = New DAO.Recordset ?
End Function
Public Function ExportToExcel(strqrySQL As String)
Dim rst As ADODB.Recordset
Dim intCount As Integer
' Create the Excel object
Set mobjXl = New Excel.Application
Set rst = New ADODB.Recordset
' Fetch the recordset
With rst
.ActiveConnection = CurrentProject.Connection.ConnectionString
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.MaxRecords = 65000 ' Approx max number of rows Excel can handle
.Open strqrySQL
End With
With mobjXl
' Add a workbook and turn off Excel updates
.ScreenUpdating = True
.Visible = False
.Workbooks.Add
.DisplayAlerts = False
.Columns.ColumnWidth = 17.5
' Add the column headers
For intCount = 0 To rst.Fields.Count - 1
.Cells(1, intCount + 1).Value = rst.Fields(intCount).name
Next intCount
' Dump the recordset to Excel
.Range("A2").CopyFromRecordset rst
.Visible = True
End With
mobjXl.ActiveSheet.Columns("A:J").HorizontalAlignment = Excel.xlCenter
mobjXl.Range("A1").Select
' Columns("A:J").Select
' With Selection
' .HorizontalAlignment = xlCenter
' End With
' Range("A1").Select
' Add your error handler
******************************************************
Do I just change:
Dim rst As ADODB.Recordset to
Dim rst As DAO.Recordset
and
Set rst = New ADODB.Recordset to
Set rst = New DAO.Recordset ?
End Function