使用按钮选择发送值以填充参数化查询和报告 [英] Using button choice to send value to populate parameterized query and report

查看:50
本文介绍了使用按钮选择发送值以填充参数化查询和报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了许多教程,介绍如何提示用户输入要发送给查询的值以过滤结果。 我无法通过按钮点击事件找到使用按钮将值发送到查询和报告的方法。 其他
字样, 有几十个单独的相同报告具有相应的相同查询,这些查询使用临床实践名称的硬编码值。 我希望有一个主报告和一个主查询,并使用按钮允许用户
选择他想要查看其数据的练习。 因此,表单上会有很多小按钮,每个按钮都会发送其练习名称值。 这意味着只需要更新一个报告和一个查询。如果您想要b
,那么该名称也必须发送到报告的原因 因为查询是在报告上填写练习的名称。

I have found many tutorials on how to prompt a user for a value that will be sent to a query to filter results.  I haven't been able to find a way to use a button to send the value to the query and a report via the button click event.  In other words,  there are dozens of individual identical reports that have corresponding identical queries that use a hard coded value for a clinical practice name.  I would like to have one master report and one master query and use buttons to allow a user to select the practice whose data he wants to see.  So there will be lots of little buttons on the form with each sending its practice name value.  This would mean only one report and one query would need to be updated with any changes. In case you're wondering, the reason the name has to be sent to the report as well  as the query is to fill in the name of the practice on the report.

这可能吗? 如果是这样,怎么样?  

Is this possible?  If so, how?  

提前致谢。

推荐答案

首先需要确保用于报表的查询没有参数或条件。所以如果你要"测试"发布报告 - 它将显示所有名称/诊所。


$
然后,您可以构建一个未附加到任何表的表单。然后使用向导创建一个组合框,让您选择临床实践名称(假设您有一些具有这些名称的表。



您这样构建这样的表格:



组合框:



但是(称之为观察报告)



按钮背后的代码如下:



DoCmd.OpenReport" rptClinic",acViewPreview ,," id ="& Me.Combo0




在上面,我假设组合框名为combo0,但当然你可以使用任何名字你比如组合框 - 上面的代码必须匹配该名称。




在上面,我假设当你使用向导来创建组合框,第一列是"id"列,然后第二列是诊所名称。




所以你只需写一个代码行。上面使用"where"子句将报告限制为ONE您在组合框中选择的记录。


$
所以创建一个空白表单,然后从功能区中放入一个组合框 - 让向导创建组合框,让它"看起来" "或者从表格中选择诊所价值,其中包括诊所名称。




使用组合框是一种很好的方法,因为当您添加新诊所时,您的表单,代码,查询和报告不需要更改或更新。




整个系统因此变为"自我维持"。



问候,

Albert D. Kallal(访问MVP 2003-2017)

埃德蒙顿,加拿大艾伯塔省


You first need to ensure that the query used for the report has no parameters or conditions. so if you were to "test" launch the report - it would show all names/clinics.

You can then build a form that is not attached to any table. You then use the wizard to create a combo box that lets you select the clinical practice name (it is assumed you have some table that has these names.

You thus build a form like this:

combobox:

buttion (call it view report)

The code behind the button would look like:

DoCmd.OpenReport "rptClinic", acViewPreview, , "id = " & Me.Combo0

In above, I assume the combo box was named combo0, but of course you can use any name you like for the combo box – the code above will have to match that name.

In above, I assume that when you used the wizard to create the combo box , the first column was the "id" column, and then the second column was the clinic name.

So you only have to write one line of code. The above uses the "where" clause which will restrict the report to the ONE record you choose in the combo box.

So create a blank form, and then drop in a combo box from the ribbon – let the wizard create the combo box, and have it "look up" or select a clinic value from the table with the clinic names in it.

Using a combo box is a good approach, since as you add new clinics, then your forms, code, query and report does not need to be changed or updated.

The whole system thus becomes "self maintain".

Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada


这篇关于使用按钮选择发送值以填充参数化查询和报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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