A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Late Binding



 
 
Thread Tools Display Modes
  #21  
Old December 26th, 2007, 01:20 PM posted to microsoft.public.access.queries
tmort
external usenet poster
 
Posts: 10
Default Late Binding

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").HorizontalAlignm ent = 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


"Tom Wickerath" wrote:

The code that uses ADO is necessary code.


And you are positive that it cannot be re-written as DAO code (since you've
already established that your database requires a checked reference to the
DAO Object Library)? If you are just hitting data in a JET database (ie.
.mdb file), you are likely better off to stick with DAO. On the other hand,
if you are accessing data from another source, such as SQL Server, Oracle,
Exchange, etc., then ADO is likely your best choice.

I take it that:

MDAC 2.1 - refers to ActiveX 2.1
MDAC 2.5 - refers to ActiveX 2.5
etc.

Is this correct?


Sounds reasonable. But do I know for sure? The answer is "no".


Here are some additional links you may find helpful:
http://support.microsoft.com/kb/814521
http://msdn2.microsoft.com/en-us/library/ms810810.aspx


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/ex...tributors.html
__________________________________________

"tmort" wrote:

Thanks,

The code that uses ADO is necessary code.

I have looked at the component checker.

I take it that:

MDAC 2.1 - refers to ActiveX 2.1
MDAC 2.5 - refers to ActiveX 2.5
etc.

Is this correct?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.