Report Design
 Crystal Reports Forum : Crystal Reports .NET 2003 : Report Design
Message Icon Topic: How to display 3 tables in a report document? Post Reply Post New Topic
Author Message
danisupr4
Newbie
Newbie
Avatar

Joined: 10 Nov 2008
Location: Indonesia
Online Status: Offline
Posts: 3
Quote danisupr4 Replybullet Topic: How to display 3 tables in a report document?
    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


Edited by danisupr4 - 10 Nov 2008 at 4:07am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
danisupr4
Newbie
Newbie
Avatar

Joined: 10 Nov 2008
Location: Indonesia
Online Status: Offline
Posts: 3
Quote danisupr4 Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.