使用带有参数的访问查询导出到文本 [英] Exporting to text using access query with parameters

查看:139
本文介绍了使用带有参数的访问查询导出到文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候语

我有一个使用内置参数(例如[开始日期])的访问查询来提示用户输入日期参数​​,当查询是跑了。

I have an access query which uses built in parameters (e.g. [start date]) to prompt a user to enter a date parameter when the query is ran.

在大多数情况下,这一切都很好,除了今天我试图将查询导出到一个文本文件,我收到一个错误:

In most cases this has worked fine except today I tried to export the query to a text file and I am receiving an error:


参数太少。预期2。

Too few parameters. Expected 2.

这是有道理的,因为查询[开始日期]和[停止日期]中有两个参数,原因是错误是我从来没有提示过提供价值。

This makes sense as there are two parameters in the query [start date] and [stop date], the reason it errors is that I am never prompted to supply a value.

如果我导出到Excel,这可以正常工作,只是不要文本文件。

If I export to Excel this works OK, just not to text files.

有关如何解决此问题或允许我将查询导出到文本文件?

Any suggestions on how to get around this issue or allow me to export the query to a text file?

谢谢,

< a href =https://stackoverflow.com/users/5836/brettski> Brett

示例访问查询:

SELECT PR_EARN.Emp_No, PR_EARN.Pay_Code, PR_EARN.Hours, PR_EARN.Rate, PR_EARN.Pay_Amt, PR_EARN.Pay_Date
FROM PR_EARN
WHERE (((PR_EARN.Pay_Date) Between [Start Date] And [End Date]));


推荐答案

一些更多的方法:


  • 有一个解决方法,在Microsoft的 KB269671

    基本上,您必须使用具有特殊语法的中间查询。

  • There is a workaround given in the Microsoft's KB269671.
    Basically, you have to use an intermediary query with a special syntax.

您还可以将查询更改为 Make Table 查询,然后导出其数据。

You can also change the query to a Make Table query and then export its data.

使用和中介不可见数据表其 RecordSource 设置为查询,然后将其 FormLoad 事件导出为文本形式,然后关闭表单。 br>
只需打开窗体即可提示用户输入参数,然后自动保存。

Use and intermediary invisible datasheet form whose RecordSource is set to the query and then have it's FormLoad event export the form to text then close the form.
Just opening the form would prompt the user to enter the parameters and then automatically save it.

罗伯特的回答可能仍然是最简单的一个。

Robert's answer may still be the simplest one though.

这篇关于使用带有参数的访问查询导出到文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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