抑制没有数据和标题的子报表 [英] Suppressing subreport with no data and a header

查看:10
本文介绍了抑制没有数据和标题的子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当简单的子报表,当没有为其选择记录时,我想禁止它.问题是我有这个子报表的页眉和页脚部分,其中包含静态元素(文本框、行等).我已将包含子报表的部分、子报表本身以及子报表中的部分设置为在没有记录时全部隐藏.然而,子报告无论如何都会显示出来.没有数据的数据部分确实被抑制了,但页眉和页脚似乎使子报表保持可见.

I have a fairly simple subreport that I want to suppress when there are no records selected for it. The problem is that I have a header and footer section of this subreport with static elements in it (text boxes, lines, etc.). I have set the section containing the subreport, the subreport itself and the sections within the subreport to all be surpressed when there are no records. Yet, the subreport shows up anyway. The data section with no data is indeed suppressed but the headers and footers seem to keep the subreport visible.

有什么想法吗?哦,我正在运行 Crystal-Reports 2011.谢谢!

Any ideas? Oh, I'm running Crystal-Reports 2011. Thanks!

推荐答案

我自己刚刚在 CR2008 中遇到了这个问题.以下是我为完成这项工作所做的步骤:

I just ran into this myself in CR2008. Here are the steps I did to make this work:

  1. 进入您的子报告(我的意思是让它在自己的设计器窗口中打开)-> 进入文件"菜单下的报告选项"-> 选择如果没有记录则禁止打印"
  2. 现在回到您的主报告.右键单击子报表 -> 转到格式化子报表" -> 点击子报表"选项卡 -> 选中禁止空白子报表"复选框.
  3. 如果子报告是主报告部分中的唯一内容,请在部分编辑器"中右键单击该部分 -> 选中禁止空白部分"复选框.

如果您的子报表确实返回了记录,但只是没有显示,那么请尝试使用共享变量.为此,您首先需要考虑用于在子报表中显示记录的逻辑.这很可能是在细节部分抑制公式中找到的任何逻辑,但它在很大程度上取决于您的特定子报表的格式.

If your subreport does return records but it is just that none are displayed then try using shared variables. To do this you need to consider the logic you're using to display the records in the subreport in the first place. This is likely whatever logic found in the detail section suppression formula, but it will depend heavily on the format of your particular subreport.

现在,在子报表的报表标题中初始化一个共享 numbervar,然后使用上述逻辑在每次显示一行时递增它.

Now, initialize a shared numbervar in your subreport's report header and then increment it each time a row is displayed using the aforementioned logic.

回到您的主报告中,您可以检查该变量的值以有条件地隐藏子报告的部分.我说可能"是因为 CR 在查看抑制公式之前可能不会评估子报表的变量之前,而是试一试.您需要在部分抑制公式中使用 whileprintingrecords; 关键字来延迟其评估.祝你好运!

Back in your main report, you may be able to check the value of that variable to conditionally suppress the subreport's section. I say "may" because CR may not evaluate the subreport's variables prior to looking at the suppression formula, but give it a whirl. You'll want to use the whileprintingrecords; keyword in your section suppression formula to delay its evaluation. Good luck!

这篇关于抑制没有数据和标题的子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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