水晶报表-调用子报表
我用的是水晶报表。我将在其中使用 2 个子报告。仅当满足某些条件时才应显示子报表。假设我们将输入指定为 0,则只应显示主报告。如果主报表输入为1,则应显示主报表和子报表1。如果输入为 2,则应显示主报告和两个子报告。我怎样才能实现这个目标?
提前致谢,
I use a crystal report. I will be using 2 subreports in it. The subreports should be displayed only when certain criteria is matched. Consider we give input as 0 then only main report shud be shown. If input to the main report is 1, then main report and subreport1 shud be shown. If the input is 2 then the main report and both the subreports shud be shown. How can I achieve this?
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
右键单击子报表并转到设置子报表格式。
在公共选项卡中,您将看到一个禁止选项。
单击旁边的自定义公式按钮 (x-2)。
输入您需要的任何公式。只要它产生布尔值即可。
在您的示例中,对于子报表 1,使用
if {input}=0 then true else false
,对于子报表 2,使用if {input}=0 or {input}=1 then true else false
。Right-click on your subreport and go to format subreport.
In the common tab, you will see an option to suppress.
Click the custom formula button next to it (x-2).
Enter whatever formula you need. Just so long as it results in a boolean.
In your example, for subreport 1, use
if {input}=0 then true else false
and for subreport2, useif {input}=0 or {input}=1 then true else false
.我会将每个子报告放在各自的部分中,但这对于完成这项工作并不是绝对必要的。但是,如果您这样做,则只需转到“部分专家”并单击“抑制(不向下钻取)”行上的 X-2 按钮。一旦到达那里,您可以执行类似
If {?MyInt} = 1 Then True
// 如果您正在检查的一个或多个条件为真,这将抑制此部分。
在这种情况下,我有一个名为 MyInt 的参数字段,如果数字为 1,它将抑制整个部分。显然,您需要再添加一个或两个“如果”来专门管理您的需求。
请记住,该字段也不必是参数字段。您几乎可以使用任何其他字段作为您的标准。另外,正如我在开始时所说的,您不必抑制整个部分。您可以通过转到对象属性上的“通用”选项卡来对单个对象(在您的情况下为子报表)执行此操作。从那里,您可以使用“抑制”复选框对面的 X-2 按钮执行相同的操作。
I would put each of the sub reports in their own section but that is not absolutely necessary to make this work. However if you do you can then just go to the Section Expert and click the X-2 button on the Suppress (No Drill Down) line. Once there you can do something like
If {?MyInt} = 1 Then True
// That will suppress this section if the condition or conditions you are checking is true.
In that case I have a parameter field named MyInt and if the number is 1 it will suppress the whole section. Obviously you will need to put in another If or two to manage your needs specifically.
Keep in mind that the one does not have to be a parameter field either. You can pretty much use any other field as your criteria. Also, as I said in the beginning, you don't have to suppress an entire section. You can do it on the individual object (in your case the subreport) by going to the Common Tab on the properties of the object. From there you can do the same thing with the X-2 button across from the Suppress check box.