Access 仅导出查询的第一列

发布于 2024-09-24 16:52:56 字数 276 浏览 6 评论 0原文

全部 - 我很尴尬地问一些看起来如此基本的问题,但我被困住了。

我使用 Access 2007 对单个 84K 行表运行查询,生成约 80K 行的结果集。我无法将结果集复制/粘贴到 Excel 中(Access 无法复制/粘贴 > 64K 行)。当我右键单击查询并导出时,无论我尝试什么格式,它都只导出第一行(ID)。

如何获得 Access 来导出整个结果集? (我尝试突出显示所有内容等。我还尝试使用“外部数据”功能区,但这只是导出原始表,而不是我运行的查询的结果集。)

谢谢!

All -
I'm embarrassed to ask something that appears to be so rudimentary, but I'm stuck.

Using Access 2007, I ran a query against a single 84K row table to produce a result set of ~80K row. I can't copy/paste the result set into Excel (Access fails copy/pasting > 64K rows). When I right-click on the query and export, no matter what format I try, it only exports the first row (ID).

How can I get Access to export the entire result set? (I've tried highlighting everything, etc. I also tried using the 'External Data' ribbon, but that just exports the original table, not the result set from the query I ran.)

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最美不过初阳 2024-10-01 16:52:56

我运行了一个查询,通过单击左上角的小箭头、CTRL-C、打开的 Excel、CTRL-V 突出显示了所有内容。全部导出了。 (当然我没有像你一样有大约 100k 行,但我不明白为什么它也不能处理这个问题。)

或者这不是你想要的?

I ran a query, highlighted everything by clicking on the little arrow in the upper left, CTRL-C, opened Excel, CTRL-V. Exported the whole thing. (Granted I didn't have ~100k rows like you, but I don't understand why it wouldn't handle that too.)

Or is that not what you want?

撞了怀 2024-10-01 16:52:56

如果您一次将 40,000 行复制到 Excel 文件中的不同选项卡会怎样?

What if you copy 40,000 rows at a time to different tabs in your Excel file?

仙气飘飘 2024-10-01 16:52:56

我在 Access 2013 中遇到了类似的问题,因此决定分享如何解决它。我解决这个问题的唯一方法是使用 VBA。

仅更新 testSQL(当您转到查询的 SQL 视图时很容易看到)和 CSV_file_path(CSV 导出的文件路径)

Sub Export_ToCSV()

Dim testSQL As String
Dim UserInput As String
Dim db As Database, qd As DAO.QueryDef

Set db = CurrentDb

testSQL = "SELECT Table1.Column1, Table1.Column2, Table1.Column3 FROM Table1;"
CSV_file_path = "C:\temp\filename.csv"

Set qd = db.CreateQueryDef("tmpExport", testSQL)
DoCmd.TransferText acExportDelim, , "tmpExport", CSV_file_path, True
db.QueryDefs.Delete "tmpExport"
MsgBox ("Finished")

End Sub

I have had a similar problem with Access 2013, so decided to share how to resolve it. The only way I could solve this issue was by using VBA.

Only update testSQL (easy to see when you go to SQL view of your query) and CSV_file_path (the file path of your CSV export)

Sub Export_ToCSV()

Dim testSQL As String
Dim UserInput As String
Dim db As Database, qd As DAO.QueryDef

Set db = CurrentDb

testSQL = "SELECT Table1.Column1, Table1.Column2, Table1.Column3 FROM Table1;"
CSV_file_path = "C:\temp\filename.csv"

Set qd = db.CreateQueryDef("tmpExport", testSQL)
DoCmd.TransferText acExportDelim, , "tmpExport", CSV_file_path, True
db.QueryDefs.Delete "tmpExport"
MsgBox ("Finished")

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文