Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Linking Tables Post Reply Post New Topic
Page  of 3 Next >>
Author Message
stevetothink
Newbie
Newbie


Joined: 18 Oct 2010
Online Status: Offline
Posts: 37
Quote stevetothink Replybullet Topic: Linking Tables
    Posted: 07 Jun 2011 at 6:09am
I'm a newbie at crystal but I understand that tables need to be linked using a common field.

I started with a standard report that had 2 tables. I added a 3rd table that has an additional field I need.

I linked the 2nd table to the 3rd table using a field called "num."

When I run the new report, it comes up blank.

Any ideas what I'm doing wrong?

Thanks in advance.
Steve
IP IP Logged
Dewald
Groupie
Groupie
Avatar

Joined: 02 Jun 2011
Location: South Africa
Online Status: Offline
Posts: 47
Quote Dewald Replybullet Posted: 07 Jun 2011 at 6:44am

There needs to be a logical relationship between fields that you link the tables on. So if you have a customer table with a customer number you can link it to a sales table on the customer number. Both of these tables, customer and sales, might have an internal ID field, but linking on the ID fields is meaningless.

 

Hope this helps.

 

Dewald Botha
http://www.ITClarity.co.za
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 07 Jun 2011 at 12:22pm
There are so many ways to link tables that sometimes you have to play around with the links.Sometimes just changing the link to a left or right outer link will fix things and sometimes you have to add another table that you don't need any information from in order to add a table you do.I'd try a left outer link and see if that doesn't cure it.You may also be running into a null value and that will kill a report especially if you're using a formula.


Edited by CircleD - 07 Jun 2011 at 12:25pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jun 2011 at 4:20am

also keep in mind that crystal joins are not "automatically enforced" when they are added to a report as they are in something like SQL. Just making the join in SQL will alter your returned data set based on the join.

In Crystal you either enforce the join in the Link Options in the DB Expert links tab or the join becomes enforced when when you use any 1 field from both tables that are joined. They can be used in any fashion in the report (referenced in formula or the select expert or just a field in the report canvas).
This explains really odd behavior when you have a report that is showing all your records, you add one field to the canvas or a formula (the first use of any field in a table) and all of the sudden your data rows disappear or go to a huge number (enforcing a cartesion product of a join).
IP IP Logged
stevetothink
Newbie
Newbie


Joined: 18 Oct 2010
Online Status: Offline
Posts: 37
Quote stevetothink Replybullet Posted: 08 Jun 2011 at 9:51am
Thanks for the tips. I played with the links and got it to return what I think is the correct date field I'm looking for.

The problem now is that the quantity fields associated with each record are being doubled.

Any idea why adding a date field would double the quantity fields the report was already displaying?

Thanks again!
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 08 Jun 2011 at 11:27am
If they are holding true to being double each time a quick easy fix would be to create a formula for that field and divide by 2.Something like {Table.Field}={Table.Field}/2 should do it.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jun 2011 at 11:44am
also ...
it is likley a a cartesion product from the joined tables.
You can try FILE >REPORT OPTIONS make Select Distinct Records as TRUE (not available for all data source types)
You can conditionally suppress rows using a NEXT(field_A)=field_A
You can use Running Totals to evaluate on change of a PrimaryKey field
IP IP Logged
Dewald
Groupie
Groupie
Avatar

Joined: 02 Jun 2011
Location: South Africa
Online Status: Offline
Posts: 47
Quote Dewald Replybullet Posted: 08 Jun 2011 at 8:37pm
Just be aware that if you do set the Select Distinct Records = True, any Valid Duplicates will allso be elimenated.
 
I would have a look at the join and see if there is another link between the tables that will make the results valid.
 
For example sometimes you would need to join on both Document Number and Document Type to make the join valid.
 
 
Dewald Botha
http://www.ITClarity.co.za
IP IP Logged
stevetothink
Newbie
Newbie


Joined: 18 Oct 2010
Online Status: Offline
Posts: 37
Quote stevetothink Replybullet Posted: 09 Jun 2011 at 9:22am
Thanks again for the help. I really appreciate it.

I changed the report so it only selects distinct records. That fixed the 2X problem I had on the quantities. However, the report now only includes terminated employees. It used to include both terminated and active employees. 

Any ideas?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jun 2011 at 9:25am
what is your select statement?
IP IP Logged
Page  of 3 Next >>
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.020 seconds.