Crystal Reports - 向“命令"查询添加参数 [英] Crystal Reports - Adding a parameter to a 'Command' query

查看:17
本文介绍了Crystal Reports - 向“命令"查询添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

水晶版 - 水晶报表 2008业务对象 - XI

Crystal Version - Crystal Reports 2008 Business Objects - XI

我编写了一个查询来填充子报表,并希望根据用户的输入将参数拉入该查询.我的问题是,我需要在Where"子句的第一行输入什么正确的语法来接受参数?

I have written a query to populate a subreport and want to pull in a parameter to that query based on input from a user. My question is, what is the correct syntax I need to put in the first line of the 'Where' clause to accept the parameter?

这是我在 Crystal Reports 中使用的查询:

Here is the query I am using in Crystal Reports:

Select 
Projecttname,
ReleaseDate,
TaskName

From DB_Table

Where
(Project_Name like {?Pm-?Proj_Name})) and 
(ReleaseDate) >= currentdate

推荐答案

我想出的解决方案如下:

The solution I came up with was as follows:

  1. 在您喜欢的查询开发工具中创建 SQL 查询
  2. 在 Crystal Reports 的主报表中,创建要传递给子报表的参数
  3. 使用报表创建向导"的数据"部分中的添加命令"选项和#1 中的 SQL 查询创建子报表.
  4. 子报表添加到主报表后,右键单击子报表,选择更改子报表链接...",选择链接字段,取消选中根据字段选择子报表中的数据:"

  1. Create the SQL query in your favorite query dev tool
  2. In Crystal Reports, within the main report, create parameter to pass to the subreport
  3. Create sub report, using the 'Add Command' option in the 'Data' portion of the 'Report Creation Wizard' and the SQL query from #1.
  4. Once the subreport is added to the main report, right click on the subreport, choose 'Change Subreport Links...', select the link field, and uncheck 'Select data in subreport based on field:'

注意:您可能必须首先添加参数并选中根据字段选择子报表中的数据:",然后在创建子报表后返回更改子报表链接"并取消选中它.

NOTE: You may have to initially add the parameter with the 'Select data in subreport based on field:' checked, then go back to 'Change Subreport Links ' and uncheck it after the subreport has been created.

在子报表中,单击报表"菜单,选择专家",使用公式编辑器",将 #1 中的 SQL 列设置为等于或类似于 #4 中选择的参数.

In the subreport, click the 'Report' menu, 'Select Expert', use the 'Formula Editor', set the SQL column from #1 either equal to or like the parameter(s) selected in #4.

                (Subreport SQL Column)  (Parameter from Main Report)
        Example:  {Command.Project} like {?Pm-?Proj_Name}

这篇关于Crystal Reports - 向“命令"查询添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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