Report crashes - crystal-reports

Hi I am trying to have a master detail report. But the report always crashes as i hit the next page on the preview. Both the queries work fine in the query editor.
Main report query
select a.Name,a.ftid,a.instno from testschema.ViewA a where a.ftid={?ftid}
Shared variables declared in main report separately
shared numbervar instno;
instno:={Command.INSTNO}
shared stringVar gnpidesc;
gnpidesc:={Command.Name}
Sub report query
select a.TOTALAMT,b.Name from testschema.ViewB a CROSS JOIN testschema.View3 b where a.ftid={?ftid} AND b.ftid=a.ftid AND b.instno={?instno} AND a.Name='{?gnpidesc}' ORDER BY a.GENGNPIDESC
Shared variables declared inside subreport header separately
shared numbervar instno;
shared stringVar gnpidesc;
I have delcared 3 parameters fields also with the same name.Sub report only shows for first row in master, if I click next page the application crashes.
Edit
The Sub report contains a cross-tab report in the sub report head section.
Report Layout
Main Report
- Details Section (Main report query)
- Details Section2 (Sub report)
- Cross-tab (Sub report Footer- Query 2)
Main Report

I'm certain I've seen this before with my own reports. You probably have some data quality/consistency issues.
Do any of your joining fields have a null value? All it takes is 1 record ;)
Do you have a formulae that references a field with a null value?
I don't know what your data source is, but do any of those views have custom formulae that Crystal wouldn't recognize? For example, I often pull data from MS Access queries, but Crystal throws an error if I use the nz() function.
One way to find your culprit is to scroll through your preview until you find the page that can't display and crashes. See what data would have displayed on there.
You'll have to either fix the data before it gets to Crystal or rework a function. Good luck.

Related

sub report to main report value passing in crystal report

I want to get sub report to main report value pass. How this possible?
this is my main report and My Need format
And sub report is-
this is my Sub report
AVGQty formula is - Sum ({Command.IssueQty})/Sum ({Command.WorkingDays})
I want to get every Item Wise average from sub report in main report using report link.
as like, Acetic Acid - AVG Qty: 128.91 (Item wise value come from sub report)
You need to use a shared numbervar in your formula.
In your case:
shared numbervar AVGQty:= Sum ({Command.IssueQty})/Sum ({Command.WorkingDays});
then in your main report you simply create a formula with:
shared numbervar AVGQty
From what i understand, you don't need callback value (shared variables) from subreport in your main report. Just include subreport dataset into your main report and link those 2 tables in database expert.
So for example you have table a which is in your main report and table b which is you subreport. You link them from itemname from table a to itemname to table b. To make this without any shared variables you should just add table b to main report, in database expert link both tables with itemname and then you can group by attribute itemname from table a to get summarizes which you want.
You can do it with shared variables or with this logic. Your choice
Hope it helps

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

crystal report, subreport details section not displaying the next batch of records

I put a subreport in the footer of my main report and I set its details section to display five records per page (through the paging tab).
I am sure my query returns nine records.
Upon previewing the report, on the first page, it displays the first five records.
However, on the second page, it also displays the first five records not the remaining four records.
I am not sure where is the problem since I just started using crystal reports. Hope you can help me. Thanks.
You need to set your sub report links.
This will link the data from your main report to your sub report. In Crystal 2008 you right click on the sub report and choose 'Change Sub report links...' option. Then you can select the data to flow from the main report to your sub report. Otherwise your sub report is being viewed as a completely separate report that you are just inserting on top of your main report and it will be the same at every instance.
Also, it might be a good idea to use groups instead of the details section when inserting sub reports.

Store sub report fields in array

Hi I want to store sub report fields per page into an array and print that array inside the report footer in main report. Any clue guys ?
If you're talking about only a few fields, then I'd recommend a shared variable taking the data back to the main report.
If it's alot of data, then you should make another subreport in the main report's footer and calculate all your data there.
Edit
Well, you asked, so here's how:
In your main report's footer, create a formula (call it FooMain) with this code:
whileprintingrecords;
shared stringvar MyLittleVar;
In your subreport, create a formula (call it FooSub) with this code:
whileprintingrecords;
Shared stringvar MyLittleVar:="This is from the subreport";
Preview your report. In the footer, the FooMain formula should display "This is from the subreport". Use FooMain in whatever calculations in the main report. Due to fundamental design aspects of Crystal, this will only work if FooMain (and any formulas that reference it) is below the subreport it is getting data from.