14

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!

4 Answers 4

22

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

  1. 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'
  2. 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.
  3. 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!

9
  • Drat! No soap. I was really hopeful thought as I didn't know about the 'Report Options' dialog under the File menu and that box was not checked. I checked it and am still getting the subreport though. Sep 19, 2012 at 18:32
  • @DanBerlyoung Does the subreport actually display anything or is it just an empty box? If you're still getting the headers/footers is it possible that the subreport is actually getting records but they're just not displaying? The subreport query needs to return 0 rows for that checkbox to actually work.
    – Ryan
    Sep 19, 2012 at 18:37
  • Aye! There the rub. The subreport does have records that are printing out in another subreport but this one, while using the same dataset, has only fields that have no value in them. So it's suppressing the detail section because there are no fields in it to print but the subreport actually has records. Is there anyway to sense weather or not any rows actually printed and then hide the subreport based on that value? Sep 19, 2012 at 18:47
  • @DanBerlyoung Ye may be wantin' to use a shared variable in the subreport to keep track o' the number of displayed records. If there be none, then suppress the subreport's section back in thar main report.
    – Ryan
    Sep 19, 2012 at 19:11
  • I'm still getting my feet under me w/ Crystal. Would I have it increment a shared var when displaying each record or is there some other way to get the number of records displayed? Sep 20, 2012 at 16:04
0

Have you tried using suppress formula?

Right click Format Field > Check Suppress > click Edit formula [x-2] button

0

Hard to follow everything in the post but if data is running into each other, then add a section and place your sub report in the section and make sure can grow is checked off.

If you have static data that you want to show, then you may want to create 2 sub reports, one with the static data and one with the dynamic data and suppress if blank.

0

Put subReport in a Section, then Right click on Section=> Section Expert Then check true 'Supress Blank Section' in the common tab as mentioned in below picture. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.