How to suppress on-demand subreport in crystal reports? - crystal-reports

In my report there is an on demand subreport. The subreport is sometimes empty and in these cases i want it to be suppressed (i.e. the caption should not be visible)
Is this possible?
I tried using the checkbox under subreport -> "suppress empty subreport". it doesnt work however.
Thanks

"Suppress empty subreport" will have no effect on an on-demand subreport - these are only run on demand, and until they have been run it is impossible to tell whether or not they will be empty.
If there is enough information in the main report to be able to tell whether the subreport will be empty - for example, if the subreport is a transaction breakdown and the main report includes the total transaction value, so that a total transaction value of 0 indicates that there will be no data in the subreport - then you can select Format Subreport in the main report section and conditionally suppress the subreport in the Common tab of the Format Editor dialog.

Related

If my SQL query in Crystal Report is not returning any data then how can I stop it from displaying

I want to stop printing of reports if no data is returned in Crystal Report. How can that be achieved?
One way to do this is to put the logic from the main report into a subreport. Then on the main report, right click on your newly created subreport and choose Format Subreport, select the Subreport Tabe then check the box that says "Suppress Blank Subreport".
That is one way to do it...

Crystal Subreport Common Headers

Maybe someone can Help me find the right technique.
I have a number of Crystal Reports that I am updating (Crystal Reports XI).
These reports each have an SQL Function associated with each that either retrieves records from the database (if any meet criteria) or returns an Empty Dataset (which happens daily).
These are executed in a batch process and directs the output to a PDF file which is emailed to users.
I am relatively new to Crystal Reports.
I am attempting to use a common SubReport to format/gather data for the Headers/Footers used in these documents. So far - most of this is working as I would expect. This allows me to use a single SubReport to generate the same Header/Footer in multiple reports (at least that's my goal).
However - I added a Report Footer section to the Main Report - my plan with this was to generate a Report Footer that would contain the following information:
A static Text Message that reads " --- END OF DOCUMENT ---"
The Report Title of the "Main Report"
The Date and Time that the Document was generated and Total Number of pages.
Sounds pretty simple.
So SubReport is named: "END-OF-DOCUMENT-SUBREPORT"
I used the "Special Fields" Data Date, Data Time, & Page N of M
Since the "Special Field" Report Title is returning me the "END-OF-DOCUMENT-SUBREPORT" value I used a Parameter field to pass the Report Title value from the Main Report to the SubReport.
This all works fine - HOWEVER - with the addition of the Linked Parameter Field from the Main to the SubReport - when I execute the report to generate the document - the SubReport ends up showing a blank Report Footer - that I can click on to reveal the "END-OF-DOCUMENT-SUBREPORT" in another Tab.
Without the Parameter field - it didn't do this and the information from the SubReport appeared on the last page of the document.
Is this a standard behavior of Crystal?
I'm not sure how to Suppress the "Drill Down" feature and still display the Report Section.
You can pass variable between you Main Report and sub Report. You can also create variable and assigned them to a sub report. As aMazing mention, creating Header and Report Footer sub report is not common. It is even messy. If you want something generic, I will create a report template that you will use in the future.
Have a good day!

Combine all SSRS reports in the Grid into one report

It should be very simple and should employ multi-value parameters , but not able to figure out how ? This report takes parameters from the GridView I have a gridview in an asp.net web page which has print button for every row to print this report for that row.
Now, there are as many reports as there are rows in the grid.---[This part is done]
So,how about combining all these reports into one single report
You can add a subreport for each one of you reports.
You just create a new report and start inserting subreports in each row.
Check this documentation:
http://msdn.microsoft.com/en-us/library/dd220581.aspx
Here's an example for you:
1 - Create a new report. You can then add a tablix to it, in case you have more info, which is the case in my example. Just don't forget to add a dataset to that tablix if that's your case.
This is how it would look
Each gray line is a subreport.
2 - To insert a subreport just right-click a cell and go to Insert > Subreport
3 - Right-click your subreport, select Subreport Properties and choose your report from the drop-down menu:
4 - You can then set the parameters your subreport will receive:
Case 2: if you don't need a tablix for aditional info, just repeat the same process in a Rectangle.
UPDATE
As I said in my comment, here's one report in which I do exactly what you want:
As you can see the subreports are part of the main report's body that has other data.
I need to repeat these subreports for each record and that's how it is done.
Here you can see the Id being passed as parameter to my subreport:
From what I understood, that's what you want. That way for each record its current Id would be passed to the report. Generating a report with that "dynamic" parameter you mentioned.

Conditional Suppressing Detail section in Crystal Report

There are 2 subreports in detail section of my report.
I have enabled suppress blank for subreports.
Now i want to suppress detail section if both subreports have no data i.e. both are suppressed.
I searched a lot on web but did not find a solution.
I'd first recommend against inserting subreports in the details section if at all possible because the subreport will be run for each record that the original report retrieves. If the report has 1000 rows it would be similar to running 1000 reports (thought not exactly).
That said, you have a couple of options.
You should be able to go into the section expert and check "Suppress Blank Section" for the Details section if you've already suppress the subreports.
If that does not work for you, you can create a formula field in each subreport that contains a shared variable that you populate the row count of the subreport. Then in the Suppress Formula (X+2 button) for the details section in the section export you can use those shared variables to enter a formula for the suppression of the section.
Here are a few links on using shared variables:
http://msdn.microsoft.com/en-us/library/ms225625(VS.80).aspx
http://books.google.com/books?
id=eukKHY9wjAEC&pg=PA316&lpg=PA316&dq=crystal+reports+passing+data+from+subreport&source=bl&ots=O8BzfeMJOK&sig=kt2v5JPbgy1bofCG6mFy4b5Qybk&hl=en&ei=wyKhSoWeHoqDngf4xZ35BA&sa=X&oi=book_result&ct=result&resnum=8#v=onepage&q=crystal%20reports%20passing%20data%20from%20subreport&f=false

Inclusion and exclusion of subreports (iReport-JasperReports)

I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.
you can in the master report get data from your data source that allows you to identify if the subreport should be included, then use the 'printWhenExpression' field on the subreport element to check that data.
I use this regularly - for example the printWhenExpression field may contain:
new Boolean($F{TOTAL_STATS}.intValue() != 0)
where TOTAL_STATS is from the master report's database query. If non-zero we show a subreport detailing some data.
From my knowledge, if there aren't any data printed in the subreport, Jasper eliminates the blank space. In other words, if your subreport would normally occupy half a page, but there is no data, then the empty space is eliminated. I'm not sure this is what you mean by including or excluding the report.
Another solution would be to place the subreport in the main report, and from right-click ->properties -> Subreport tab, you select the "Subreport condition" tab and write your condition there. If the condition is true, the content of the subreport will be printed, otherwise it won't be printed.
Jamie Love's answer about "printWhenExpression" is on target.
if there aren't any data printed in the subreport, Jasper eliminates the blank space
Actually, at least in JasperReports 3.7.0 there is a subreport property "Remove Line When Blank" that controls that behavior. By default - at least when I use iReport - that parameter is off.
WEG