以编程方式将参数传递到访问报告中 [英] Pass a parameter into an access report programmatically

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

问题描述

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

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.

我已更改运行报告的查询以使用 ID 值的参数,因此现在单击按钮时,Access 会提示输入要报告的记录 ID,并且报告显示应有的效果.

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?

推荐答案

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

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

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

那就是

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

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

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