是否可以将当前表单的Recordset传递给DoCmd.TransferText [英] Is it possible to pass the current form's Recordset to DoCmd.TransferText

查看:72
本文介绍了是否可以将当前表单的Recordset传递给DoCmd.TransferText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i试图找出是否可以将表单的当前记录集传递给DoCmd.TransferText,以便我可以将其导出为.csv

我知道我可以使用querydef等,但如果我可以循环遍历我的subform1并获取嵌套的subform2记录集并将它们传递给例程,那将是一个更好的解决方案。


有没有人有这方面的经验?

任何想法都会受到压倒性的赞赏!

解决方案

@ sakurako97


您可以编写代码来处理Recordset,然后将所有字段的值动态写入CSV文件。


@ADezii


谢谢......应该进一步了解它!


< blockquote>我为你创建了一个Generic Sub-Routine来说明我正在制作的点。只需将任何DAO Recordset传递给此Routine,它将从其内容为您生成CSV文件。为了简单和简洁起见,我已经消除了任何错误检查并将Recordset中的所有字段视为文本。此例程是从表单上的命令按钮的Click()事件调用的,其Record Record恰好是Northwind示例数据库中的Products Table。

展开 | 选择 | Wrap | 行号

hi,
i am trying to find out if it is possible to pass the current recordset of a form to DoCmd.TransferText so i can export it as a .csv

I know I can use querydefs etc, but it would be a much nicer solution if i could just loop through my subform1 and get the nested subform2 recordsets and pass them to the routine.

has anyone had experience with this ?
any ideas would be overwhelmingly appreciated!!

解决方案

@sakurako97
You can write code to process a Recordset, then dynamically write the Values for all Fields to a CSV File.


@ADezii
thanks...shall look further into it!


I created a Generic Sub-Routine for you to illustrate the point that I was making. Simply pass to this Routine any DAO Recordset, and it will generate a CSV File for you from its contents. For the sake of simplicity and brevity, I''ve eliminated any Error Checking and treated all Fields in the Recordset as Text. This Routine is called from the Click() Event of a Command Button on a Form whose Record Source happens to be the Products Table from the Northwind Sample Database.

Expand|Select|Wrap|Line Numbers


这篇关于是否可以将当前表单的Recordset传递给DoCmd.TransferText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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