1
votes

I have a crystal report with several parts

  • Page Header a (Company Information)
  • Page Header b (Sub-Report: has list of specific countries)
  • Page Header c (Sub-Report: has list of specific Products)
  • Page Header d (Sub-Report: has list of specific items)

The data source of the report is given by a Dataset "DS1" through C# Application (Push Method)

Because of the complex logic in the background, it is decided to have Dataset "DS1" with 4 Data tables (tbl0,tbl1,tbl2,tbl3) to hold separately the correct data in the Dataset.

The dataset doesn't have any relationships, because I have loaded directly the final data result in the relative Data Tables in the Dataset

DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
DataTable dt3 = new DataTable();
DataTable dt4 = new DataTable();

Load_CompanyInfo(country_ID, ref dt1);
Load_Countries(_ApprovalID, ref dt2);
Load_Products(_ApprovalID, ref dt3);
Load_Items(_ApprovalID, ref dt4);

_ds_tmp.Tables.Add(dt1);
_ds_tmp.Tables.Add(dt2);
_ds_tmp.Tables.Add(dt3);
_ds_tmp.Tables.Add(dt4);

In the Form ReportView.cs, I have assigned the Dataset to the report.

rep_c_single.SetDataSource(ds.Tables[0]);                   // Main company info
rep_c_single.Subreports[0].SetDataSource(ds.Tables[1]);     // countries
rep_c_single.Subreports[1].SetDataSource(ds.Tables[2]);     // products
rep_c_single.Subreports[2].SetDataSource(ds.Tables[3]);     // items
rep_c_single.Refresh();
cr_Viewer.ReportSource = rep_c_single;

on the report file, the sub reports doesn't have link field to the main report. Because final Data is prepared in the Data Tables. I just want to display the Data in the Sub report independent from the Main Report data source.

What I have till now, the sub reports lists all countries and all products, not what in the data table exists.

EDIT: It is important to mention: the sub reports and main reports don't have any relations. I want only to PUSH data to the relative Sub-reports

thanks for any help

1

1 Answers

0
votes

i'm not entirely sure.. but i've done this once..

  1. make sure your report has a group based on the primary key of the main report (with which you want to link all the sub reports)

  2. right click on the sub report

  3. change sub report links

  4. in the available fields select the column name of the sub report or respective data table

  5. click on add to add it into the fields to link it'll also show in the sub-report paramater to use drop down list underneath

  6. check the flag -- select data in sub-report based on field

  7. select the main report primary key group you made in the first step

Hope it works.. :)