Suppress Subreport in crystal reports - 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.

Related

Passing Value from Sub Report To MainReport on Crystal Reports

I'm currently having a problem with regards on Crystal Report Shared Variable. this is my situation.
I have a Report consist of multiple sub reports (and of course the main report). i need to expose a value in main report from Sub Report, but the problem is i need to Display it before the sub report was rendered. Please see the image below:
As you can see the image above, i need to display the value below (Sub report with RED encircle with VALUE) on the TOP (Red encircle without value).
I used Shared Variable but i think it will not work since the TOP will be first rendered (where i need to display the Value from subreport) before the Below(where i need to get the value).
Is it possible?
The section that displays the value has already been rendered by the time the other section sets the value of the shared variable.
Two options:
add a second instance of the subreport to a section that precedes the section when you want to display its value; you won't be able to suppress either the section or the subreport, so you will need to make the subreport as small as possible and change the font colors to white
use a sql-expression field to calculate the desired value and avoid the subreport complexity altogether

Passing Subreport Value to Main Report

In my Report I am passing the Total of Subreport to display in the Main Report for that I am using the below Formula,
In Subreport,
WhilePrintingRecords;
Shared Numbervar EvTotal:= cdbl({Evaluation_Details.NOOFCOPIESEVALUATED})
In Main Report,
Shared NumberVar EvTotal;
EvTotal;
but when I Include the Formula for displaying in the Main Report it is Dispalying "0" instead of Total of SubReport
A couple of things:
You have some typos in your code. Here you were missing the semi-colon at the end:
WhilePrintingRecords;
Shared Numbervar EvTotal:= cdbl({Evaluation_Details.NOOFCOPIESEVALUATED});
And here you don't need the semi-colon:
Shared NumberVar EvTotal;
EvTotal
And as #Raphael pointed out, 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 "EvTotal" at the end of the first formula, that way you can see what the value is/should be.
The formula that you created in the sub-report must be placed in the detail section or Group header. You can hide this field. Then it will show up the correct value.

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 - Hide Page Header on First Page

I have a report that needs to show a report header on page 1, and a different header on subsequent pages.
This seems simple enough; if I add pagenumber=1 and goupnumber=1 to the suppress formula for the second header, it will only be shown after the first page. However, the report is also supposed to reset the page count several times in a single group, thus leaving several pages that match those criteria.
Is there another field in Crystal reports that could have a unique value for the first page? Or is there another way I might go about solving this?
You have to specify in the Selection Expert - Suppress Formula the following formula:
PageNumber = 1
In the Supress Formula try this Formula
Drilldowngrouplevel = 1 ;
or
PageNumber=TotalPageCount
You have to specify in the Selection Expert - second header - Suppress Formula the following formula:
PageNumber <> 1

Suppressing subreport with no data and a header

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.