将搜索结果从表单导出为CSV(宏) [英] Export search results from Form to CSV (macro)

查看:73
本文介绍了将搜索结果从表单导出为CSV(宏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索表单,将记录返回到另一个表单,而不是表格。以下是我的问题:


1)是否可以将表单结果(而不是查询结果)导出为CSV?我之前成功地输出了一个结果表,但不是表格。


2)如果是这样,可以通过宏来完成吗?

3)如果宏可以,宏可以进一步允许用户在导出时选择位置和文件名吗?


我尝试了一种直接的指向方法宏的形式,但似乎宏只需要一个表或查询。我的猜测是我必须在幕后建立一个进一步的查询才能导出...


谢谢,


-Scott

I have a search form that returns records to another form, rather than a table. Here are my questions:

1) Is it possible to export the form results (as opposed to query results) to CSV? I''ve been successful at exporting a table of results before, but not a form.

2) If so, can this be done via macro?

3) If a macro is possible, can the macro further allow the user to choose location and filename when exporting?

I''ve tried a straightforward approach of pointing the macro to the form, but it appears that the macro only wants a table or query. My guess is that I will have to build a further query ''behind the scenes'' in order to export...

Thanks,

-Scott

推荐答案


我有一个搜索表单,可以将记录返回到另一个表单,而不是表格。以下是我的问题:


1)是否可以将表单结果(而不是查询结果)导出为CSV?我之前成功地输出了一个结果表,但不是表格。


2)如果是这样,可以通过宏来完成吗?

3)如果宏可以,宏可以进一步允许用户在导出时选择位置和文件名吗?


我尝试了一种直接的指向方法宏的形式,但似乎宏只需要一个表或查询。我的猜测是我必须在幕后建立一个进一步的查询才能导出...


谢谢,


-Scott
I have a search form that returns records to another form, rather than a table. Here are my questions:

1) Is it possible to export the form results (as opposed to query results) to CSV? I''ve been successful at exporting a table of results before, but not a form.

2) If so, can this be done via macro?

3) If a macro is possible, can the macro further allow the user to choose location and filename when exporting?

I''ve tried a straightforward approach of pointing the macro to the form, but it appears that the macro only wants a table or query. My guess is that I will have to build a further query ''behind the scenes'' in order to export...

Thanks,

-Scott



1.表单结果无法转移到CSV文件。要将数据导出到CSV文件,请使用TransferText()方法,此方法需要表或查询参数,而不是SQL语句。您必须首先创建一个查询,然后在Table Name参数中指定查询的名称。但是,所有内容都不会丢失,因为如果通过更改表单的RecordSource生成表单结果,则可以通过以下代码以编程方式创建CSV文件,该代码基于表单的RecordSource创建Recordset并将所选字段写入CSV格式到测试目录中的CSV.txt。字段名称是我自己的测试用途。

1. Form results cannot be transfered to a CSV File. In order to Export data to a CSV File, you use the TransferText() Method and this Method requires either a Table or Query Argument, not an SQL Statement. You must first create a query and then specify the name of the query in the Table Name argument. All is not lost however, because if your Form results are generated by changing the RecordSource of the Form, you can programmatically create the CSV File by the following code which creates a Recordset based on the Form''s RecordSource and writes selected Fields in a CSV Format to CSV.txt in the Test Directory. Field names are my own for testing purposes.

展开 | 选择 | Wrap | 行号


实际上,这是一个很好的解决方案,我会尝试一种变体(借用ADezii的代码是......

Actually, that is an excellent solution, one variation I would try (borrowing ADezii''s code) is ...

展开 | 选择 | Wrap | 行号



实际上,这是一个很好的解决方案,我会尝试的一种变体(借用ADezii的代码)是...... 。

Actually, that is an excellent solution, one variation I would try (borrowing ADezii''s code) is ...

展开 | 选择 | Wrap | 行号


这篇关于将搜索结果从表单导出为CSV(宏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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