[英]2 Access queries on same Excel WorkBook different Sheets
I want to export 2 Access
queries to the same Excel
WorkBook
so query 1 goes to Sheet1
and query 2 goes to Sheet2
.我想将 2 个
Access
查询导出到同一个Excel
WorkBook
因此查询 1 转到Sheet1
,查询 2 转到Sheet2
。 I am using Access
& Excel
2010我正在使用
Access
& Excel
2010
I am using the following code我正在使用以下代码
'------------------------------------------------------------
' ExportToExcel
'
'------------------------------------------------------------
Function ExportToExcel()
On Error GoTo ExportToExcel_Err
DoCmd.OutputTo acOutputQuery, "TRERequired_Summary", "Excel97-Excel2003Workbook(*.xls)", "C:\Users\OWNER\Desktop\Test\TRERequired_Summary.xls", False, "", , acExportQualityScreen
DoCmd.OutputTo acOutputQuery, "TRERequired", "Excel97-Excel2003Workbook(*.xls)", "C:\Users\OWNER\Desktop\Test\TRERequired_Summary.xls", False, "", , acExportQualityScreen
ExportToExcel_Exit:
Exit Function
ExportToExcel_Err:
MsgBox Error$
Resume ExportToExcel_Exit
End Function
What is the question? 有什么问题 I didn't try your code;
我没有尝试您的代码; only eyeballed it.
只盯着它。 Seems like it should do what you want it to do.
似乎它应该按照您想要的去做。
One over-writes the other.一个覆盖另一个。 Try this:
尝试这个:
DoCmd.TransferSpreadsheet acExport, , "TRERequired_Summary", "C:\Users\OWNER\Desktop\Test\TRERequired_Summary.xls", True
DoCmd.TransferSpreadsheet acExport, , "TRERequired", "C:\Users\OWNER\Desktop\Test\TRERequired_Summary.xls", True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.