Passing Subreport Value to Main Report - crystal-reports

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.

Related

crystal report shared variable from sub report to main report?

in my sub report
shared Numbervar myTotal:= SUM({SP_Project;1.alloted});
myTotal;
and in my main report..a make a formula
shared Numbervar myTotal;
SUM({#byAppro},{#byOffice}) + myTotal;
and i get the right total..but when i make another formula using the same shared variable
shared Numbervar myTotal;
SUM({#byAllo},{#byOffice}) + myTotal;
this time it didn't work..the myTotal becomes 0 which is it should have the same value from the 1st formula..why is that ? is it ? it can only be use once ?
The formula that is not working is probably in the same section as the subreport and the formula that IS working is probably in a later section. Formulas are evaluated before subreports when they are in the same section.
You can split the section into A and B subsections, keep the subreport in A and move the formula to the B subsection. That should work.

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.

How to sum running total field for each group in crystal report?

i have problem in crystall report,
Here is my code following many reference site in google,
// {#reset}
//place in group header
whileprintingrecords;
global numbervar Sum_Cumm_Sum:=0;
// {#increment}
//place in section detail
whileprintingrecords;
global numbervar Sum_Cumm_Sum:=Sum_Cumm_Sum+{#getIP};
// {#display}
//place in group footer
whileprintingrecords;
global numbervar Sum_Cumm_Sum;
Where getIP is Formula,
{#sumKN}/{#sumSKS}
and code in it is running total field with reset on change group,
{#sumKN} is running total field for field KN
{#sumSKS} = is running total field for field SKS
============================================================
I use all this code, but in Sum_Cumm_Sum:=Sum_Cumm_Sum+{#getIP}, I can't get the right value.
Here is my report view:
http://i.stack.imgur.com/CSmsB.png
To the extent I see as you placed in detail section your formula is working correctly, Now you want to see the summation of values in footer then you need to write saperate formula to sum index.... in footer section so that it sumarizes it saperatley.
Either use a manual running total OR a running-total field, not both. By the way, a running-total field only works in a footer section.
A better approach:
{#sumKN} - field is {table.KN}; summarize for all records; reset after change in group
{#sumSKS} - field is {table.SKS}; summarize for all records; reset after change in group
// place in `footer` section
//{#ratio}
// optional
// EvaluateAfter({#sumKN});
// EvaluateAfter({#sumSKS});
{#sumKN} / {#sumSKS}

Suppress Page Footer After Subreport

I'm trying to suppress all the page footers on the main report on all pages that have a subreport and I'm having some trouble.
The subreport is in the report footer and starts on a new page. The subreport could be 1 or 10 pages so doing it by page number is out.
I've tried setting a global variable in the main report header and setting it to false and then changing the variable just before the subreport section (I change the variable in report footer a, and then the subreport is in report footer b) to true and then tried to suppress the page footer based on that global variable but to no avail.
I feel like I'm really close but just missing something. Any help would be awesome.
Hi Try this it will work
1) Create this formula and place it on the Group Header 2 Section:
whileprintingrecords;
numbervar x := x + 1;
"";
2) Create this formula and place it on the Page Header Section:
whileprintingrecords;
numbervar x := 0;
"";
3) Go to the Section Expert > Select the Page Footer Section > Click the formula button beside 'Suppress' and use this code:
numbervar x = 0;
Let me know how this goes.
You have the right idea, but are probably just missing a detail or two.
In the report footer, create a global boolean variable and then suppress the page footer based on this variable. BUT, you need to use the whileprintingrecords keyword for both formulas. Ex:
//Declare variable in report footer
whileprintingrecords;
booleanvar suppressFooter := true
//Suppress page footer
whileprintingrecords;
booleanvar suppressFooter

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.