Print Page | Close Window

How to display 3 tables in a report document?

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4756
Printed Date: 02 Apr 2025 at 9:57am


Topic: How to display 3 tables in a report document?
Posted By: danisupr4
Subject: How to display 3 tables in a report document?
Date Posted: 10 Nov 2008 at 4:05am
hello, i develop a VB .NET application using crystal report (Visual Studio 2008 OEM).
In my application, I have defined a dataset (an XSD file), and I have 3 DataTable in it. In application runtime, I filled up the 3 DataTable.
I made them independent each other so that there is no need to define links.

I want to display their records in one report, exactly one RPT file. In the Section 'Details' of RPT file, I put one field/column in each DataTable I have defined before. When I run the application, there are some duplicate records in the table whose less record. For example, table A has 2 records, table B & table C each has 1 record, then duplication happened on record in table B & C. It can says that, the number of the rows in the Section 'Details' always been forced to have number of rows in the most DataTable
Here is the illustration (assume I only fetch 1 column in each table):

table_A    table_B    table_C
-------    -------    -------
recordA1   recordB1   recordC1
recordA2   recordB1   recordC1


then I try to have some experiment without usage of DataSet, I use 2 tables from MySQL database, and they are independent too. Table A has 2 records and table B has 3 records.
And then it displayed like this:

table_A     table_B
-------     -------
recordA1   
recordB1
recordA1    recordB2
recordA1    recordB3
recordA2    recordB1
recordA2    recordB2
recordA2    recordB3

it looks like a cross-products between 2 tables

Actually I understand if they have a shared-field then I must define a key within the report displayed, but in the case they are independent each other.

How I fix this case?

thank you ... Smile



Replies:
Posted By: hilfy
Date Posted: 11 Nov 2008 at 4:10pm

Crystal will automatically do a cross-product if you don't define links between your tables.  However, there may be a way around this using subreports.

In your main report, use just one table.  Create a top-level "dummy" group on either a value that is common to all of the records or create a formula like this "not IsNull({table.NeverNullField})" on a field that will never be null and group on it (the point is to have only a single group value at this level!)  Set the Group Header section for this group to "Underlay Following".  Place your Table_A data in the details section.
 
Create a subreport for Table_B.  DO NOT LINK it on any field!   Place it in the Group Header you just created so that it is positioned to the right of the  Table_A data and is the width you want for your Table_B data.  Create a group for this subreport like you did for Table_A and turn on Repeat Group Header on Every Page.  Suppress the Report Header and Footer.  Place your Table_B data in the details section.
 
Create another SubReport for Table_C, following the same steps as for Table_B.
 
You may have to play with some of the positioning to get things to line up correctly, but this should display all of your data.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: danisupr4
Date Posted: 11 Nov 2008 at 9:24pm
thank you very much, hilfy.
An hour after I posted the first message, I tried to use subreport and it worked perfectly.

And after I read the reply from hilfy, then I'm sure that I did the right thing in my CR application Big%20smile



Print Page | Close Window