禁止无数据和标题的子报表 [英] Suppressing subreport with no data and a header
问题描述
我有一个非常简单的子报表,当没有选择任何记录时,我想隐藏它。问题是我在此子报表的页眉和页脚节中包含静态元素(文本框,行等)。我已将包含子报表的部分,子报表本身以及子报表中的部分设置为在没有记录时全部被压缩。但是,子报表仍然显示。确实没有数据的数据部分被抑制了,但是页眉和页脚似乎使子报表可见。
有什么想法吗?哦,我正在运行Crystal-Reports2011。谢谢!
我在CR2008中遇到了这个问题。这是我完成此工作的步骤: )->进入文件菜单下的报告选项->选择如果没有记录则禁止打印
编辑:如果您的子报表确实返回了记录,但只是没有显示它们,那么请尝试使用共享变量。为此,您首先需要考虑用于在子报表中显示记录的逻辑。这可能是在详细信息部分抑制公式中找到的任何逻辑,但是在很大程度上取决于您特定子报表的格式。
现在,在子报表的初始化一个共享数字var报告标题,然后使用上述逻辑在每次显示一行时将其递增。
返回主报表后,您可以检查该变量的值以有条件地隐藏子报表的部分。我之所以说可以,是因为CR可能不会在查看抑制公式时对子报表的变量之前进行求值,但会稍作调整。您需要在部分抑制公式中使用 whileprintingrecords;
关键字来延迟其评估。祝你好运!
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.
Any ideas? Oh, I'm running Crystal-Reports 2011. Thanks!
I just ran into this myself in CR2008. Here are the steps I did to make this work:
- Go into your subreport (by that I mean have it open in its own designer window) -> go into 'Report Options' under the 'File' menu -> select 'Suppress printing if no records'
- Now go back into your main report. Right-click on the subreport -> go to 'Format Subreport' -> hit the 'Subreport' tab -> check the 'Suppress Blank Subreport' checkbox.
- If the subreport is the only thing in the main report section, go into that section in the 'Section Editor' by right-clicking on it -> check the 'Suppress Blank Section' checkbox.
EDIT: 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.
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.
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屋!