根据查询为报表设置参数 [英] Setting a parameter for a report based on a query

查看:68
本文介绍了根据查询为报表设置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正面临着Access的一个问题,尽管谷歌搜索了几个小时,但我还是找不到解决方案,所以我希望有人这里有帮助!


我有一个报告 - rptClientsByCountry - 它基于一个查询 - qryClientsByCountry - 它接受一个参数myCountry来过滤结果。我需要能够根据用户选择的国家/地区生成此报告,最好是从下拉列表中生成。


暂且不说表格部分,我无法弄清楚如何将字符串传递给报表,以便它接受它作为基础查询的参数。 Psuedo代码为:


sub command_click()


获取国家当前价值下降


在报告中设置参数myCountry


DoCmd.OpenReport" rptClientsByCountry",acViewPreview


end sub


可以这样做吗?或者我是否必须在DoCmd.OpenReport上设置Where条件?


提前致谢!

Hi all,

I''m facing an issue with Access that I haven''t been able to find a solution for, despite hours of googling, so I hope someone here can help!

I''ve got a report - rptClientsByCountry - which is based on a query - qryClientsByCountry - that takes a parameter, myCountry, to filter the results. I need to be able to generate this report depending on the user''s choice of country, preferably from a drop-down list.

Leaving aside for a minute the form part, I can''t figure out how to pass a string to the report such that it accepts it as the parameter to the underlying query. Psuedo code would be:

sub command_click()

get current value of country drop down

set parameter myCountry on report

DoCmd.OpenReport "rptClientsByCountry", acViewPreview

end sub

Can this be done? Or must I resort to setting the Where condition on the DoCmd.OpenReport?

Thanks in advance!

推荐答案

它的工作原理就像一个表格

It works just like a form

展开 | 选择 | Wrap | 行号



它只适用于像一个表格

It works just like a form

展开 | 选择 | Wrap | 行号



这个方法意味着你摆脱了参数本身。

...

如果你更换了用DoCmd.OpenReport执行你仍会收到参数的提示。

所以就像karanj一样,我很好奇是否有人知道你是否可以/如何将参数传递给select查询,这样用户就不会收到提示?
This method implies you get rid of the parameters per se.
...
if you replace the execute with DoCmd.OpenReport you still receive a prompt for the parameter.
So like karanj I''m curious if anyone knows if/how you can pass a parameter to a select query so the user does not receive the prompt?



是的,确切地说 - 这种基本模块化非常有用! 官方我发现的解决方案有点令人沮丧 - 请参阅这篇关于office.microsoft.com网站的文章。当然这意味着查询报表形式将有效地耦合得非常紧密?

Yep, exactly - this kind of basic modularisation would be very helpful! The "official" solution that I''ve found however is a little disheartening - see this article on the office.microsoft.com site. Surely that means that the query-report-form will effectively be coupled quite tightly?


这篇关于根据查询为报表设置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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