D
Dion
I have some OpenRecordset / CopyFromRecordset code that I
have used successfully in the past. I created a new copy
of the code, and now get a "Run-time error '13': type
mismatch" error. I have chaecked everything I can think
of, and can not find anything different in this new code
than I had in the original code.
My complete code:
Sub zzz()
Dim xlApp As Excel.Application
Dim db As Database
Dim QDef As QueryDef
Dim rs As Recordset
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Workbooks.Add
.ActiveSheet.Name = "LPlus"
With .Sheets("LPlus")
Set db = CurrentDb
Set QDef = db.QueryDefs("zQTest")
Set rs = QDef.OpenRecordset()
.Range("A2").CopyFromRecordset rs
End With
.ActiveWorkbook.SaveAs "c:\temp\ABSPatList.xls"
.Quit
End With
Set xlApp = Nothing
End Sub
The "Set rs = QDef.OpenRecordset()" is where I get the
error. The query "zQTest" is a simple SELECT query. I
verified this works.
What am I missing?
Thanks
Dion
have used successfully in the past. I created a new copy
of the code, and now get a "Run-time error '13': type
mismatch" error. I have chaecked everything I can think
of, and can not find anything different in this new code
than I had in the original code.
My complete code:
Sub zzz()
Dim xlApp As Excel.Application
Dim db As Database
Dim QDef As QueryDef
Dim rs As Recordset
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Workbooks.Add
.ActiveSheet.Name = "LPlus"
With .Sheets("LPlus")
Set db = CurrentDb
Set QDef = db.QueryDefs("zQTest")
Set rs = QDef.OpenRecordset()
.Range("A2").CopyFromRecordset rs
End With
.ActiveWorkbook.SaveAs "c:\temp\ABSPatList.xls"
.Quit
End With
Set xlApp = Nothing
End Sub
The "Set rs = QDef.OpenRecordset()" is where I get the
error. The query "zQTest" is a simple SELECT query. I
verified this works.
What am I missing?
Thanks
Dion