如何构建查询或报告w /参数列表,以逗号分隔。 [英] How do you build a query or report w/ list of parameters, separated by commas.

查看:76
本文介绍了如何构建查询或报告w /参数列表,以逗号分隔。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个两部分问题......我是在解决了一个问题,但我想到了两种可能的方法来实现这个目标。


我想拥有rptCustomer_Inquiry_Report将列出特定的,用户定义的客户的客户信息。它们将由Customer_Number标识。例如,我希望提示输入客户编号,然后输入10628,10654,11369。当我进行查询并将条件设置为参数[输入客户编号]时,如果我输入多个参数,我得到零结果。


一个想法是让查询工作。我只需要知道如何允许用户输入多个值并让数据库实际上给我所需的结果。这需要什么样的查询?


另一个想法是在实际报告中使用参数。我不太自信这是可能的和/或直截了当的。我没有找到关于在报告中指定参数的太多信息,但我可能会发现这在其他情况下很有用。


请提供建议或提供意见。我在Access时仍然很新,所以不要以为我知道的太多了。 :-)

非常感谢。

This is a two part question... I''m after one solution but I''ve thought of two possible ways to make this work.

I want to have a rptCustomer_Inquiry_Report that will list customer information for specific, user-defined customers. They will be identified by their Customer_Number. For example, I want to be prompted to Enter Customer Numbers and then enter "10628, 10654, 11369". When I make a query and set the criteria to the parameter [Enter Customer Numbers], if I enter more than one parameter I get zero results.

One idea is to get a query working. I would just need to know how to allow the user to enter the multiple values and have the database actually give me the desired results. What kind of query would this require?

Another idea is to use a parameter in the actual report. I''m less confident this is possible and/or straightforward. I haven''t found too much info on specifying a parameter in a report, but I may find this useful in other situations.

Please advise or offer opinions. I am still very new at Access so don''t assume I know too much. :-)
Thanks so much.

推荐答案

打开一个具有数据源的报表,该数据源基于单个或可变数量的参数可能有点棘手。我创建了一个代码模板,可以做到这一点。用户将在名为txtCustomers的文本框中输入单个或多个逗号分隔的客户ID。代码将解析此String,然后生成要在OpenReport方法的WHERE子句中使用的SQL语句。根据需要替换您的值,如果您有任何问题,请随时提出。
Opening a Report that has a Data Source which is based on a Single or Variable number of Parameters can be a little tricky. I created a Code template that will do just that. The User will enter either a single or multiple Comma Separated Customer IDs into a Text Box named txtCustomers. The code will parse this String, then generate an SQL Statement to be used in the WHERE Clause of the OpenReport Method. Substitute your values as required and should you have any questions, feel free to ask.
展开 | 选择 | Wrap | 行号


我已附加了我的数据库。我从BYTES得到了一些非常聪明的帮助,所以你看到的任何东西都非常方便......可能是我的想法与其他人的提示和代码配对。


我的回答问题是你的问题是我永远无法弄清楚代码的放置位置。事情变得越来越好......我的速度有了明显的改善......但我仍然有点慢。 (我只有3个星期进入Access。)


那么,我将把这个代码放在哪里你引用...以及如何调出文本框进入参数?到目前为止,我的参数文本框已被MS Access调用,我刚刚输入参数名称和类型。我想我只是从表单和报告中输入代码,所以我想这个代码必须附加到报告中的属性框。特别说明表示赞赏。


如果你想查看我的数据库,我试图让这个参数运行的报告命名为rptHOTSTICK_CUSTOMER_INQUIRY。客户编号和客户信息所基于的查询名为HOTSTICK_CUSTOMERS Query。非常感谢您的帮助和时间。





I have attached my DB. I have had some pretty intelligent help from BYTES so anything you see pretty handy...probably was my idea paired up with someone else''s hints and code.

My problem with answer''s such as yours is that I can never figure out where to put the code. I''m getting better with things..my speed is definetely improving...but I''m still a little slow. (I''m only 3 weeks into Access.)

So, where would I put this code you refer to...and how do I call up the text box to enter the parameters? So far my parameter text boxes have been called up by MS Access where I have just entered in the parameter name and type. I think I''ve only entered code from forms and reports so I''m thinking this code has to attach to the properties box in the report. Specific instructions are appreciated.

If you want to look at my DB, the report I''m trying to get this parameter to run is named rptHOTSTICK_CUSTOMER_INQUIRY. The query the customer number and customer info is based from is named HOTSTICK_CUSTOMERS Query. Thanks so much for your help and time.
附加文件
SHOPS102009.zip (146.9 KB,91 views)
Attached Files
SHOPS102009.zip (146.9 KB, 91 views)


Danica,


此代码应该适合您,它将在您要触发运行报告的命令按钮的Click事件过程中。


如果您发布当前运行报告的程序,我相信我们任何一方都可以告诉您如何合并此代码以便它适合您。


PS。术语在Access中非常重要。田野不是控制。理解术语对于理解我们所说的内容非常有帮助(反之亦然)。如果有任何你不确定的问题,我们很乐意启发。
Danica,

This code should work for you and it would be in the Click event procedure of the Command Button that you want to trigger running the report.

If you post the procedure where you currently run the report, I''m sure either of us can tell you how to incorporate this code so that it works for you.

PS. Terminology can be very important in Access. Fields aren''t controls. Understanding the terminology can be very helpful to you in understanding what we are saying (and vice-versa of course). If there''s ever anything you''re not sure of simply ask and we''ll be pleased to enlighten.


这篇关于如何构建查询或报告w /参数列表,以逗号分隔。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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