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. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
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 | |
|
|