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

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...

Related

Linking fields to subreport

In my main report I have some fields which I need to use in my subreport.
Right now I'm loading one csv file in both the main and the sub reports, but this seems to slow down the preview of my reports (I need these reports in a program). Eve if I use the preview in Crystal Reporst, it loads 3 times the same database, so I was thinking about linking the fields.
So I do Right Click on Subreport -> Change Subreport Links... and then I put the fields I want on the right side of the shown table. But when I do a preview of the whole report, in the subreport it shows only the first line and not all the values inside.
How do I manage to make the subreport show all the values of the fields?

Crystal Reports: Setting subreport parameters with one main report parameter [duplicate]

How can we pass a parameter from the main report to a subreport in Crystal Reports XI? I have a parameter in the main report. Now, I want to pass the same parameter to subreports. Please help me.
Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport.
Using CodebyMoonlight's solution requires a relation between main report and subreport.
If there is no relation between both of them, you can use Shared Variables to pass values between both of them, as shared variable can be set and displayed anywhere in main report or sub report.
Shared NumberVar x := 5;
Perform following easy steps:
Create New Parameter lets say "StartDate" in Parameter Fields in Field Explorer in Crystal Report
Create New Parameter lets say "StartDateSubReport" in Parameter Fields in Field Explorer in your Subreport
Now in Main report file, Right Click Subreport lets say "EmployeesList.rpt" and click Change Subreport Links menu
Select "StartDate" from Available Fields from Available Fields Tab and click on ">" button to make it vailable to link in subreport
Now bind your "StartDate" which you have made available by selecting it with "StartDateSubReport" in dropdown available in "Subreport Parameter Field to use"
parameter sharing between main report and sub report "Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport." works for me
I had the same problem. The main report loaded first and then the subreport. You have to load the subreport before you can use the variable.
I think that using
Right Click and Sub-report Links
or
Shared Var Between Report and Sub-report
Both using Selection formula so it is suitable for limited data only
Selection formula working after loading all records from Database table ... report loading bad performance
so i'm tring to limit rows by passing some parameter from C#/VB and send others from main to sub report
For example if you need the transaction of items in period and you can pass the period parameter from application (c# ..) and using Sub-report Links to send itemID
https://kb.blackbaud.com/articles/Article/52328
Create a parameter field in the main report.
From the main report, right click on the subreport, and select Change Subreport Links.
In the subreport linking window, select the parameter field from the window labeled "Available Fields", and click on the ">" button to move it to the window on the right labeled "Fields to link to"
Below, make sure you have a check next to Select data in subreport based on field.
Below the checkbox, if it is not already there, select the field from the subreport, to which you would like the parameter field linked.
Click OK

Crystal Reports: How can a not on-demand subreport be displayed as a link in the main report

I am struggling to fix a subreport where data is obtained at the point when the main report is generated and the subreport to be displayed as a link, similar to an on demand subreport.
The issue that I have if I use a non on demand subreport is that it cannot be represented as a link, it is displayed inside the main report. As well as an on demand report is not suitable to my case because the data is retrieved when the subreport is opened.
I would appreciate any help.
Thanks in advance!
You have to take the another header for subreport and also drilldown the Header and on the Suppress formula write the formula Drilldowngrouplevel = 0 and for the Sub Report take the another detail section and on the supress formula write the formula Drilldowngrouplevel = 0.
This will definitely work, because I tried it.
Can you add a group level to the subreport and add a single line into the group header?
This will mean you will have to drill down twice to get the data though.

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.

How to suppress on-demand subreport in 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.