查询设计 - 如何设计一个可以使用不同输入的查询 [英] Query design - How to design one query which can use different inputs

查看:75
本文介绍了查询设计 - 如何设计一个可以使用不同输入的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

情景:

我有不同国家/地区的政策列表。到目前为止,我所做的是我为每个国家设计了一个查询,以便为该国家制定政策。该报告基于此查询。但是,通过这种方式,我创建了很多查询。


我想要做的是设计查询(以及报告),以便我可以通过以下方式提取国家/地区的政策只需从下拉菜单中选择一个名称。


表和字段如下:


表[国家]

CountryID

CountryName


表[政策]

PolicyID

CountryID

PolicyDetails


你能告诉我这是否可能,如果是的话,如何实现这个目标?


谢谢,

SG

Hello,

Scenario:
I have list of policies for different countries. What I have done so far is that I have designed a query for each country which will pull out the policies for that country. The report is bases on this query. However, this way I am creating lot of queries.

What I want to do is design a query (and therefore the report) so that I can pull out the policies for a country by simply selecting a name from a drop down.

Tables and Fields are as below:

Table[Country]
CountryID
CountryName

Table[Policy]
PolicyID
CountryID
PolicyDetails

Could you please advise if this is possible and if yes, how to achieve this?

Thanks,
SG

推荐答案

是的,这很容易。


您应该像往常一样设计报告,除非您没有对国家/地区ID应用过滤器。然后在打开报告时传递(并应用)过滤器。


假设你有一个组合框,你选择了你的国家,我们称之为cmb_SelectCountry。您现在可以选择使用AfterUpdate事件或使用如下代码创建一个按钮:
Yes, that is quite easy.

You should design your report as you normally would, except you do not apply a filter on the country ID. Then you pass(and apply) the filter when you open the report.

Lets imagine you have a combobox in which you have selected your country, lets call it cmb_SelectCountry. You can now choose to either use the AfterUpdate event or make a button with code like so:
展开 | 选择 | Wrap < span class =codeDivider> | 行号


感谢SmileyCoder。


对不起,我在VB编码中几乎为零:-(。


我做事的方式是:


步骤1 - 我首先使用查询设计构建查询。在Criteria字段中,我使用的国家名称是我想要的策略。

步骤2 - 保存后查询,我使用报表向导根据保存的查询生成r eport。


所以,我现在不使用和Combobox(只是在查询设计中使用Criteria)。


鉴于我的情况,请你告诉我如何实现我的目标?


非常感谢,

SG
Thanks SmileyCoder.

Sorry,I am almost zero in VB coding :-(.

The way I am doing things are:

Step 1 - I am building the query first using Query Design. In the Criteria field, I am using the Country name for which I want the policies.
Step 2 - After saving the query, I am using Report Wizard based on the saved query to generate the report.

So, I am not using and Combobox at the moment (just using the Criteria in the Query design).

Given my situation, could you please walk me through how do I achive my objective?

Many thanks,
SG


在您的查询中,在 CountryName 字段中,在条件行中写下:国家/地区?

运行查询,回答问题,让我知道这是否对你有帮助。


干杯


PS:打开报告
In your query, in field CountryName, in the Criteria row write this: Country ?
Run the query, answer to question, and let me know if this help you.

Cheers

PS: Open the report too


这篇关于查询设计 - 如何设计一个可以使用不同输入的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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