简体   繁体   English

2 在同一个 Excel 工作簿不同的工作表上访问查询

[英]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.

相关问题 比较同一工作簿中的两个不同的Excel工作表 - Comparing two different Excel sheets in same workbook 在Excel工作簿的工作表中枚举查询 - enumerate queries in sheets of an excel workbook 使用访问权将多个查询导出到具有不同工作表的excel中 - Export multiple queries from access into excel with different sheets Excel 使用同一工作簿中两个工作表之间的一个数据连接创建多个 MS 查询 - Excel create multiple MS Queries using one data connection between two sheets in the same workbook 在python中的同一工作簿中创建Excel工作表 - Creating Excel sheets in same workbook in python 在Excel中将数据保存在工作簿的不同表中 - Saving data in Excel in different sheets of a workbook Excel VBA复制工作表格式不同的工作表 - Excel vba copying sheets different workbook format 如何在同一个Excel工作簿中将两个不同的CSV文件转换为两个工作表? - How to convert two different CSV files into two sheets in the same Excel workbook? VBA代码用于在同一Excel工作簿中使用来自两个不同工作表的更新来填充MI电子表格 - VBA Code to populate an MI spreadsheet with updates from two different sheets in the same Excel workbook 使用循环将多个工作表复制到同一工作簿中的多个不同工作表中 - Using loop for copying several sheets into several different sheets in same workbook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM