Suppressing subreport with no data and a header - crystal-reports

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!

Have you tried using suppress formula?
Right click Format Field > Check Suppress > click Edit formula [x-2] button

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.

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.

Related

CR | Open subreport by clicking on database field in main report

this case is a little more difficult I think.
In my main report I have material numbers displayed in a cross table.
From time to time I need to show more details for one of the material numbers. Therefore I want to double click this field and then copy the corresponding material number to the sub report (directly in the parameter field). Another fixed parameter field is the date, which has the max date "today" and the min date "today-365d".
Moreover I donĀ“t want to make the sub-report visible in the normal report the whole time. It should just be visible if I double click a material number.
Is there any possible way to that?
Thanks in advance!
You can do this in 2 ways, with either an on-demand sub report or by utilising the drill down
Using sub reports
In your main report go to insert>Subreport. Create your sub report with the detail you wish to see, then click the tick box for "On-demand subreport". Place the sub report in the details section along with your material numbers. You'll see it appear like a hyperlink. Right click then Format Subreport>Subreport tab. You can change the Subreport caption to the material number from your data by clicking the formula button for "On-demand Subreport Caption" and entering your material number field name as the result of the formula.
Whjen you ruin the report you can click the link to see the etail in the subreport
Drill down method
Create a report with all the detail you need in the details section. Group by material number then in section expert (Report menu) use the tick box to "Hide (Drill-Down OK)" the details section. Now when you preview the report the group header will show with the material number, clicking this group header will open the details section.

Suppress Subreport in crystal reports

I want to suppress my subreport, if one of the field, used in subreport is empty, so i need the formula for it, actually, now i can able to suppress the subreport based on the fields which are used in main report only, so please provide the solution for it, thanks in advance.
Solution 1:
1) Create a formula in your subreport. which is your condition to hide/show the subreport. Something on the following lines
WhilePrintingRecords;
Shared Stringvar formulaName:= if (condition) then '1' else '0';
// you can use true /false as well
2) On the main report create another formula
Shared Stringvar formulaName;
formulaName
3) Then use this formula to hide the subreport or section on the main report.
Note: it is important that you have the subreport higher in the hierarchy than the formula in the Main Report that calls the variable. I would also suggest to have "WhileReadingRecords;" in both, that way you ensure they evaluate at the same time. Also, as a little debugging help, put "formulaName" at the end of the first formula, that way you can see what the value is/should be.
Solution 2: If that does not work, create a duplicate copy of your subreport and place it on a section above existing subreport and suppress it. Then use solution 1.

Force Page Break before Row based off formula?

I am new to crystal reports. I have built a simple report that is populated by values from a stored procedure. I'm trying to place a page break before the row if the value of one of the returned items from the stored procedure is equal to a specific string. Is this possible? Thanks in advance.
Depending on your version of Crystal Reports, in the Section Expert under the Paging tab you should have the option to specify page breaks using a formula.
Hope that helps,
Chris
Yes this is possible. Right click on the section like Report Detail, Report footer etc and there will be an option to insert page break.
Against that option there will be a symbol of formula.
In the formula, specify the formula:
if(Report field...)="comparable string"
then true
else false
And you are done. You can ask again if this is not clear.
you can break a page using section expert.
Steps for produce:-
Right Click on Detail Section->Click on Section Expert->Click On Paging Tab->select CheckBox(New page Before) ->Click on Formula Button.
here will open a popup window and put below code in formula window.
if{YOUR_REPORT_FIELD_NAME}="xyz" then
True
else
False
when your field value find "xyz" then page will be break.
if want any clarification , please comment.

Crystal-Reports XI - sub report unwilling to split over two pages

I have checked and "keep together" is not ticked. I have un-checked this within the details section of my sub report but still makes no difference + I have also tried "blank page before" option with a formula of 1 = 2 but had no joy
...any thoughts?
I know this is an old post, but this of for anyone else looking for this same answer:
Go into Format SubReport, uncheck the Keep Together on the Common tab.
More information? What happens to the report/ subreport? Does the rest of the subreport "disappear" across the main report page boundary? Does the subreport not expand to fill the main report? Does the subreport run past the page boundaries (tries to print down into the page footer)?
There are multiple places to set "Keep Together" behaviour: the main report section that the subreport lives in (Section Expert, "Keep Together"); the subreport format options (right click on subreport, Format Subreport, "Keep Object Together"; and sections in the subreport. The
Also, make sure the sub-report is set to Can Grow.

Inserting a Page break into an SSRS report

I have a report in SSRS that contains 12 subreports. After each subreport, I need to insert a page break so that each subreport starts on a new page and doesn't share pages with the other subreports. Does anyone know how to do this? Thanks
I found an answer. Use a Rectangle at the bottom of each SubReport after all Tablixes and other rendering Objects. Then set its "PageBreak" property to "End". When the SubReport is finished with the Tablix and/or other data objects, the Rectangle forces a page break. Also, a cool feature, if the SubReport returns no rows of data, the page break is not rendered. Therefore, no extra page breaks
Another solution would be to have the subreports placed inside the rectangles. I would imagine this would help you to better control and organize the layout of the report.
I tried the other answer here but my master report is driven by a dataset so didn't quite work out. This is how I got it to work for me:
1) I put the subreports into different rows on top of same size rectangles inside a Tablix with all the rows belonging to the same row group.
2) I then selected properties of the group, then pagebreak and checked the property pagebreak on between each instance of group.
Just use the "Add page break after" on the General tab of Tablix Properties.
I came across the same kind of issue but I was able to overcome by below mentioned way.
I created a sub report and placed rectangle inside the sub report (page break option checked before) and placed all my sub report content inside the rectangle. This page break works only if the sub report renders any data if not they will be no page break.
I have made Many reports with a front Page Summary and Page 2 with the Detail.
Use the Tablix for the Page Break
Tablix > Properties > PageBreak > BreakLocation > Start / End / ......
Like other answers mention, I used the "Page break before" option on rectangles/tables, but for some reason it would only break the page if it wasn't at the very top of the (sub)report