0
votes

In visual studio 2010, using crystal reports. I want to generate a new report for every new value. This way all the reports can be printed together. For example if I printed as a PDF it would be one pdf file for X number of reports. However each report should look like it is a completely seperate, generated report. So with it's own unique page header values, page numbers, etc.

I have lets say a list of orders. This list is a subset of all the orders. I want to using code set what that list is. Then I want Crystal Reports to generate a report for each order and have them one after another.

Example:
-Order1 Pages 1 to 3 (Of Order1 unique data, with own separate report header&page headers)
-Order2 Pages 1 to 2 (Of Order1 unique data, with own separate report header&page headers)
-Order3 Pages 1 to 4 (Of Order1 unique data, with own separate report header&page headers)
-Etc..

I have figured out how to send multiples values to a report in one parameter, these will all be displayed if the field is put into the details section (Order1, Order2, Etc). If the field is put into the header section only the first value displays. This however does not get me a new report for each new value.

I don't know if parameters are the right option or how to do so. Grouping doesn't appear to be quite right because it just groups values within the same report. I don't know if subreports are the right thing to look into but I don't need a main report with totals to print out.

Edit Changed title, added a bit more info.

3
Are you trying to burst a report?craig

3 Answers

0
votes

You can do this using subreports. However in subreports page headers / footers are not available. They will be set in the main report. If subreports doesn't work for you, you can create a small application which will run the reports one by one and print them or will export them to PDFs and will combine the result to one big PDF. There are 3rd party tools on the market, which can be used I this scenario. Let me know if this is an option and I will post links.

Main report with subreports will be the easiest solution and will not require additional software.

0
votes

This is called report bursting. At least one of the 3rd-party Crystal Reports desktop schedulers listed at http://kenhamady.com/bookmarks.html provides that functionality.

hth, - ido

0
votes

It took me a while but I got it figured out, it was my first time attempting to use crystal reports. Crystal reports can be quite a challenging project to implement! In a nutshell I was trying to recreate a very old crystal report that had a lot of functionality.

First I was trying to let the user decide whether to print one order or several orders, all user defined before crystal reports generates. Then send that data to the report using code. This would allow the user to print essentially what was several different reports with once button click.

Somewhere between starting and now you have to make sure you connect to your datasource. In my case is was a SQL database. This gave me a lot of problems! Perhaps due to having to use a very old sqlserv32.dll because of our old ERP software. I used a OLE DB Connection, Selected SQL Server Native Client 10.0 (For SQL server 2008). Then I had to install both a Crystal Runtime 32bit and Crystal Runtime 64bit and sqlncli.msi on every client, which allowed crystal reports to run on client workstations.

My code to send a parameter to crystal reports.

string OrderList = "";

OrderList += "18528-7" + ",";
OrderList += "18527-2" + ",";
OrderList += "18532-2" + ",";

Etc..Which can be accomplished better with a loop, just done this way for testing purposes.

//Set Crystal Report Parameter.  This parameter must be created in crystal reports designer with the same name.  The parameter type must match your code type, ie a string.
CrystalReport11.SetParameterValue("@MyCrystalReportParameter", OrderList);

In Crystal Reports (CR) to accept the multi value parameter I used Select Expert. I used my Order SQL field and used the formula:

{MySQLTable.MySQLField} in split({?@MyCrystalReportParameter}, ",")

Within CR you have to create a group for the parameter you sent and want to create multiple reports for. The groups will allow a new report to be tacked on to the end of the last report for every value you pass, in my case it was Orders. This gives you Page Headers and Report Bodies with different data for every new value (my order number).

In CR I then used Group Expert and created a Group. The Group was set as my SQL Order Field.

To have resetting Page Numbers for each distinct Order Report I Suppressed the following sections: Report Header, Group Header, Details Section, Report Footer, Page Footer. I used Page Header for My Report Headers. I used Group Footer for my various sections, inserting Additional Group Footers as needed. These contained my various sections and SubReports which displayed tables of additional data such as shipment lists, parts lists, etc.

In Group Expert for my Group By Orders Database Field I checked New Page after 1 Visible Group and Repeat Group Header on Each Page.

In Section Expert On the Last Group Footer on the Paging Tab I selected Reset Page Number After. Checking Keep together on the Common Tab might be important as well.

For each SubReport which contained essentially my dynamic data tables that would grow depending on the number of data rows in my database. I right clicked on the SubReport and selected SubReport Links, selected the field and added it to Field(s) to link to. Selected it in both drop downs below and made sure Select data in SubReprot based on field was checked. In my SubReport I had to create a group to order my data in a certain way, but suppressed the groups sections and just used ReportHeader and Detail Sections.