如何以编程方式将参数传递到访问报告中? [英] How do I pass a parameter into an access report programmatically?

查看:44
本文介绍了如何以编程方式将参数传递到访问报告中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的Access MDB.我在运行现有报告的现有表单中添加了一个命令按钮.所做的更改是,此按钮需要传入一个包含要报告的记录的ID的参数-当前,该报告在MDB中的每条记录上运行.

我已经更改了运行报表的查询,以使用参数作为ID值,因此现在单击按钮时,Access会提示您输入要记录的记录ID,并且报表应显示为应该的样子. /p>

但是,我终生无法弄清楚如何将参数传递到报表中以供查询使用.我该怎么办?

解决方案

DoCmd.OpenReport方法具有各种参数,其中之一是Where语句:

DoCmd.OpenReport"rptReport", acViewPreview,,"ID=" & Me.ID

那是

expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

I've got an existing Access MDB. I'm adding a command button to an existing Form that runs an existing report. The change being made is that this button needs to pass in a parameter containing the ID of the record being reported on - currently the report runs on every record in the MDB.

I've altered the Query that the report runs on to use a parameter for the ID value, so that now when the button is clicked Access prompts for the record ID to report on, and the report displays like it should.

However, I can't for the life of me figure out how to pass a parameter into the report for the query to use. How can I do this?

解决方案

The DoCmd.OpenReport method has various arguments, one of which is a Where statement:

DoCmd.OpenReport"rptReport", acViewPreview,,"ID=" & Me.ID

That is

expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)

这篇关于如何以编程方式将参数传递到访问报告中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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