Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Null Fields and Table Joining Problems Post Reply Post New Topic
Author Message
prin1939
Newbie
Newbie


Joined: 27 Jan 2012
Location: United States
Online Status: Offline
Posts: 2
Quote prin1939 Replybullet Topic: Null Fields and Table Joining Problems
     Posted: 01 Feb 2012 at 4:36pm
< ="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 12">< name="Originator" content="Microsoft Word 12"><>

I am attempting to join 4 tables together in a very simple 4 field report. 

The tables are joined like this:

Equipment

Circuit

TML


Equipment

Component

TML


The report is very basic.  Each Table has an "ID" field (Equipment.ID, Circuit.ID, etc.). I'm attempting to display the ID fields only. 

Another thing, the tables do not link to each other using the ID fields.  Instead they use serial numbers (or sequence numbers) to make connections.

The problem is that when I attempt to run the report, only the records that have Component IDs show up.  The records that do not have Component IDs associated with a TML ID are suppressed.  I’d prefer if all my TML IDs would show up in the report.

I’ve tried many different approaches to solve my problem.  Here are some of the attempts I’ve made

1.      Unlink the Component and TML table. 

a.       This creates a ton of duplicate records.  Using the table.field=previous(table.field) formula in the section expert does not work correctly.  It pulls a random Component ID into the report, not the one associated with the record.  Perhaps this has something to do with unlinking the tables…and no, it doesn’t work if I link the tables back.

2.      Using a if isnull() formula field

a.       The formula field works but the report will still suppress records or duplicate records depending on how my links are set.

 

I’d appreciate any insight on how to create this seemingly simple report.



Edited by prin1939 - 01 Feb 2012 at 4:42pm
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 01 Feb 2012 at 9:48pm
I don't actually link tables using Crystal, I prefer to create SQL commands.
 
However, in the table joining interface when you join your component table to your TML table there should be a line between the two tables? If you right click on that line and choose properties (or some other option of similar description) - the link should be described as a "Inner Join" which means it will only display results which are present in both tables.
 
You need to change this to a left or right join (dependant on how you've link all of your tables) - At a guess I'd say a left join but I can't be certain without seeing it for myself.
 
We'll assume a left join is correct, what the left join will do is return all records from your TML table regardless of whether there's a corresponding entry in your component table.
 
Hopefully that helps.
 
Regards,
Ryan.
IP IP Logged
prin1939
Newbie
Newbie


Joined: 27 Jan 2012
Location: United States
Online Status: Offline
Posts: 2
Quote prin1939 Replybullet Posted: 02 Feb 2012 at 6:39am
Thanks Ryan!
 
I unlinked the Equipment and Component tables, and kept the link between the Component and TML tables.
 
I set the table link between the Component and TML table like this
"Component.field > TML.field".  That made the Component table the primary table and the TML table the lookup table.
 
I then made the link a "Right Outer Join".  By doing this, the report returns every record in the TML table including records where the Component ID field is empty.
 
I guess you can use either join method, right or left, it just depends on which table is the primary table and which is the lookup table.
 
I appreciate the help.
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 02 Feb 2012 at 10:25pm
Originally posted by prin1939

I guess you can use either join method, right or left, it just depends on which table is the primary table and which is the lookup table.
 
That's correct, I just didn't know which was your primary table! ;-)
 
Glad I could help,
Ryan.
IP IP Logged
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