开发者

crystal report- calling subreport

开发者 https://www.devze.com 2023-02-12 22:15 出处:网络
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. I

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 subre开发者_高级运维port1 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,


  1. Right-click on your subreport and go to format subreport.

  2. In the common tab, you will see an option to suppress.

  3. Click the custom formula button next to it (x-2).

  4. 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, use if {input}=0 or {input}=1 then true else false.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消