将MS-Access表单结果导出到Excel? [英] Exporting MS-Access form results to Excel?

查看:73
本文介绍了将MS-Access表单结果导出到Excel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Access的新手.我在将MySQL和MySQL与PHP集成在一起以创建基于Web的数据库搜索引擎方面有一些经验,但是我很难理解Access的某些概念.

我有一个小型数据库,大约有200个条目,每个条目有20个字段.我已经编写了一个表单,通过使用VBA对数据库运行SQL查询来搜索它,并以数据表模式将结果显示为另一种形式(这是执行此操作的标准方法,还是有更好的方法?)/p>

我希望能够添加一个按钮以将这些结果导出到excel(或csv或tab或其他内容,这并不重要).但是,我不确定如何使用表单结果.整个数据库很容易,但是我找不到有关如何执行此操作的文档.有没有办法做到这一点?还是我做错了吗?

如有需要,我可以提供更多详细信息.

解决方案

您说"我已经编写了一个表单,以使用VBA对数据库运行SQL查询来进行搜索,并以数据表模式显示结果改成其他形式".

如果要在数据表视图中表示实际表单,则可以使用DoCmd.OutputTo方法将该表单的数据导出到Excel.

  DoCmd.OutputTo acOutputForm,"frmResults",acFormatXLS,_"C:\ SomeFolder \ ExportedResults.xls" 

但是,如果要在数据表视图而不是实际表单中打开查询,则可以导出查询的结果集.

  DoCmd.OutputTo acOutputQuery,"qryResults",acFormatXLS,_"C:\ SomeFolder \ ExportedResults.xls" 

如果愿意,可以选择其他OutputFormat而不是Excel.在Access的帮助"主题中找到OutputTo方法,以查看可用的选择.

I'm kind of new to Access. I've got some experience working with integrating MySQL and Oracle with PHP to create web-based database search engines, but I am having difficulty understanding certain concepts with Access.

I've got a small database with around 200 entries with 20 fields each. I've written a form to search it by using VBA to run an SQL query against the database and displays the results in datasheet mode to a different form (is this the standard way of doing this, or is there a better way?)

I want to be able to add a button to export those results to excel (or csv or tab or whatever, it doesn't really matter). However, I'm not sure how to do this with the form results. Its easy with an entire database, but I can't find documentation on how to do this. Is there a way to do this? Or am I doing this wrong?

If at all required, I can provide more details.

解决方案

You said "I've written a form to search it by using VBA to run an SQL query against the database and displays the results in datasheet mode to a different form".

If you mean an actual form in datasheet view, you can export that form's data to Excel with the DoCmd.OutputTo method.

DoCmd.OutputTo acOutputForm, "frmResults", acFormatXLS, _
    "C:\SomeFolder\ExportedResults.xls"

However, if you're opening a query in datasheet view, rather than an actual form, you can export the query's result set.

DoCmd.OutputTo acOutputQuery, "qryResults", acFormatXLS, _
    "C:\SomeFolder\ExportedResults.xls"

You can choose a different OutputFormat instead of Excel if you wish. Look at Access' Help topic for the OutputTo method to see the available choices.

这篇关于将MS-Access表单结果导出到Excel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆