|
Question : Recordset in adp
|
|
I'm trying to work with recordset code with an adp (SQL Server back end). Is there any reason I would get mismatch references when doing this? My code is below (code is to move data to Excel):
Dim xlWB As Object Dim myfield As Variant Dim xlApp As Object Dim rs As Recordset Dim iRowCnt As Long ' Set object variable equal to the OLE object. Set xlApp = CreateObject("Excel.Application") ' Set xlWB = GetObject("c:\ole_test.xls", "excel.sheet"). Set xlWB = xlApp.Workbooks.Open("u:\underwriting\arew_norm.xls") Set rs = Me.Recordset xlWB.Sheets(1).Range("K1").CopyFromRecordset rs '******************************** ' Set the Visible property of the sheet to True, save the ' sheet, and quit Microsoft Excel. xlWB.Application.Windows("arew_norm.xls").Visible = True xlWB.Application.ActiveWorkbook.SaveAs filename:="U:\Underwriting\New Submissions\testing2.xls" xlWB.Application.ActiveWorkbook.Close xlApp.Quit ' xlApp.Visible = True ' Clear the object variable. Set xlWB = Nothing Set xlApp = Nothing
This should work fine, but I keep getting a type mismatch error on the Set rs line (I've tried using Dim rs As DAO.Recordset, Set rs = Recordsetclone, but get the same result).
Again, is this being caused by the Access FE and SQL BE setup?
Kevin
|
|
Answer : Recordset in adp
|
|
Try changing your recordset object to an ADO recordset:
Dim rs As ADODB.Recordset
Set rs = New ADDOB.Recordset Set rs = Me.Recordset
|
|
|
|