Trying to pass variables across sub reports and reports - crystal-reports-2008

I have a report that displays user data and a sub report displaying payment data. I want to tailor my report if there are no payments in the sub report.
The issue I am having is sharing shared variables from the sub report but this only works anything below the sub report. I also tried creating a formula function that calls a count on the amount field and if the count is above 0.00 then it has payments. But For some strange reason crystal report creates 2 of the same pdf's.
How can i find out if there are any records in the sub report and pass that true / false value around the report it inherits?
what i have tried
// tried putting this in sub report header but unable to pass it anywhere above the sub report and when adding it to the top level report it duplicates the pages.
WhilePrintingRecords;
Shared NumberVar RunningTotal;
RunningTotal:= 0;
RunningTotal:= Count({ScheduledComponents_ReportData;1.Amount});
thanks....

Shared variable values from a subreport can be used in the main report only in a section BELOW the subreport section.

Related

passing array values to a subreport

I am new to crystal report and I need a help.
I have a report having two groups,project id and work_item. And I placed 3 sub reports material,labor and equipment reports in the work item group. They pass a value to the main report that is used for further calculation which is specific for a work item..
Since it's a work item specific,I placed the final result in the work item group footer.
I placed another sub report called bill of quantities in the work item group footer that needs the final value. It's also work item specific The value being passed is fine but I am having issues with the format.
After displaying the detail of one work item,the sub reports detail follows it which I didn't want that to be displayed. I tried placing the sub report in the project id group footer. The format I need is good but the value being passed is the same for all work items in the sub report.
The thing I need is after displaying all the details of the main report then displays the sub report detail.
Is there a way to store those final values of the work items in an array and pass them to the sub report.
Well, Yes you can store details in an array, when you are loading the main report, loop thorugh the data of the main report :
shared stringvar array items;
for int i:=1 to limit(count of project_id)
do
(
whileprintingrecords;
items[i]:= //add values, you can make a logic, this is just the demo
);
items;
Then simply place this formula in a section suppressed, just above the subreport, so that this can be passed with values in the subreport.
Declare a formula, and use the shared values:
shared stringvar array items;
numbervar count_i:=//get the count of items and add array values into another formula/field.
//place that field in subreport, this may require some brainstorming from your end, but this is the way in general.

Crystal Reports 2008 conditional sub reports prompt for parmeters twice

I am using crystal reports 2008 in PeopleSoft with a SQL Server backend. I have a Master report with an underlying query which filters on parameters passed to Crystal Report (EMPLID and Calendar Year these are the underlying tables' Primary Keys).
The master report has sub reports all linked to the the master's EMPLID and Calendar Year fields.
At this point everything works I enter the emplid and year at the prompt and the report runs filtering on those fields.
Each year, the report will change. I set up the subreports so that when I enter 2014 in the prompt, the 2014 version of sub report A will display. If I enter 2015, the 2015 version displays.
When I add these parallel subreports, I get prompted twice. I have checked all of the sub report links. I have made sure that each link selects data in the subreport based on the master field, not the subreport parameter field. I have tried this with conditional subreports and conditional sections and get double prompts. I am stumped. Any ideas of how to use conditional subreports in this way without being prompted more than once?
If this works I intend to add sub report versions for each year. If anyone can think of a better approach feel free to let me know. Thanks.
Firstly...
Have created similar parameters in sub report as main report and linked both sub report and main report parameters using sub report links? If you have not done that then will suggest you to do that so that only once parameters are prompted.
Now.. I don't think your approach is suggested where you are manually adding one sub report for one year, What I would suggest is you to take only one sub report and pass the parameter to the Record Selection formula of the sub report so that I will pick data as per the parameter and your report will also be not complex.
Let me know if you have any different issue.

Sub Report with a view type datasource returns empty when a parameter is passed

I have a crystal report with few sub reports . i am passing an id to each sub reports as a parameter . So far, three of the four sub reports are fine. But one of them returns empty when ever a parameter is passed. All the sub reports used view type data source
The sub report link between the main report and the sub report that fails is set as below
under the sub report section formulas.
{CONTACTNUMBERVIEW.debtorid} = {?Pm-JobSheetReport.id}
The {CONTACTNUMBERVIEW.debtorid} is a column in the subreport and the {?Pm-JobSheetReport.id} is from the main report. It always returns null. However when i remove the parameter it returns record. I take the id to the view and it shows three records.
I am really confused, where did i go wrong? I did everything i could remember. Please any help would be appreciated.
To the extent I see this {CONTACTNUMBERVIEW.debtorid} = {?Pm-JobSheetReport.id} linking is the problem... where it is returning zero records... try to link the correct field that produces records.
Edit:---------------------------------------------------------------------------------------------
Check the query generated by the sub report and run it against the database to spot the issue that the report is generating.
Since you are able to see the data when adding the field to view perform the same operation on generated query so that you will get the idea on what to make change in crystal with respect to query.
Perform both operations that will solve the issue.

How to limit filter for sub report graph in crystal report..?

I’m new to crystal reports and I’m using crystal report 11. I have created a crystal report with a sub report and that sub report filtered by 2 user parameters named “EMP_NAME” and “EVALUATION_YEAR”. Within the sub report I insert a group and in group footer I insert a chart. That chart filtered from above 2 user parameters and from group parameter.
The problem is I need to filter my sub report from “EMP_NAME” and “EVALUATION_YEAR” while filtering my chart only from “EMP_NAME” and GROUP PARAMETER.
Is there any way to do this?
Thank you.
Requirements:
subreport displays one employee
subreport displays one year's of employee data
subreport includes a graph of all years' of employee data
Solution:
Create an {?Employee Name} parameter in the the main report; link it to {TABLE.EMP_NAME} in the subreport
Create an {?Evaluation Year} parameter in the main report; create an {?Evaluation Year} parameter in the sub-report; link two parameter fields; DO NOT LINK TO DATA.
Create a graph in the sub-report that will display all years' data (for said employee); place in header section
In the sub-report, insert a group on EVALUATION_YEAR; suppress footer; create conditional formula to suppress header if {EVALUATION_YEAR}<>{?Evaluation Year}; suppress details section.

Duplicate data of sub report at Details section in main Report

Please help me !
I have a problem in Crystal Report at visual studio::
I have 2 sub reports within the main report , and I put them at main Details section , when i run the report , the sub reports duplicated many times ..
thanks for solution .
Placing subreports within the details section will reproduce the subreport each time the Details section is printed.
If you want the subreport only once; you will need to ensure that there is only one detail line printed on the main report. Or you could place the subreports in a header/footer.
A more detailed answer will require more detailed information about your report.
Put subreports in group section in main report..and don't pust subreport in detail section
this will solve your issue...
Sub report duplicates problem in report header.
Let say, you have field Employee Name in your report header.
That name comes form dataset and dataset has 5 rows, each row repeats same employee name.
So your sub report in detail section will repeats 5 times.
Fix your header data first and duplicates should go away.
If you want to print subreport in detail section one time,
just add header section, then check underlay following section option in section expert,then place subreport where you want to print.

Resources