Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subreporting Post Reply Post New Topic
Author Message
vandersee
Newbie
Newbie


Joined: 10 Aug 2008
Online Status: Offline
Posts: 6
Quote vandersee Replybullet Topic: Subreporting
     Posted: 18 Apr 2011 at 6:39pm
I have 2 tables containing customer sales data.  Table1 contains sales of spare parts and Table2 contains sales of vehicles.  Both tables contain the field called contact_code to identify a customer and both tables can contain multiple entries per contact_code. 

I want to produce a report that details the total sales values from both tables per contact_code, so my main report refers to Table1 and a sub report interrogates Table2.

My problem is that the report only displays the information I want in the following circumstance.
1. When a customer has transactions in Table1 but not Table2
2. When a customer has transactions in Table1 and Table2

It does not display any customer who has transactions in Table2 but not Table1.

I thought the answer might be a Left Outer Join between the main and subreports, but, according to some research, this isn't possible.  How do I go about retrieving all the info I want?

Thanks for any assistance you can offer.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Apr 2011 at 3:59am
the reason it isn't working is that the value needs to exist in table1 to be seen as parameter to the subreport that lookes at table2.  The join in this case shouldn't make a difference as there is never an entry in table 1 that will trigger the subreport to display for table2.
 
I like stored procs, as they can easily get around this type of situation.  A possibility is to have a an entry from Table1 for null values, or to have a 2nd subreport that displays entries in table 2 that don't have entries in table 1
 
OR
 
use your contract_code table(I would assume that there is one) as the 'main' table in your report, then you can left outer join both table1 and table2 to it, and you can have the contract_code from the main table be the link to the subreport, then all contracts entries should be found as you are no longer relying on the value existing in Table1 to find the value in Table2
 
HTH
IP IP Logged
vandersee
Newbie
Newbie


Joined: 10 Aug 2008
Online Status: Offline
Posts: 6
Quote vandersee Replybullet Posted: 20 Apr 2011 at 7:44pm
Thanks very much for your reply.

I don't know anything about stored procs, so I have followed your second suggestion.

If I may, I will provide you with some further information, as I have tried what you suggested and my results are no different.

The main report contains the contact table and the sales transaction table for spare parts, linked with a left outer join using the contact code field.
The subreport also contains the contact table along with the sales transaction table for vehicles.  These are also linked with a left outer join by the contact code field.  The two reports are linked by contact code.

Because I am only interested in total value of transaction by contact code (and not individual transaction values), I have grouped both reports by contact code, hidden the Details section and displayed what I want in the Group Footer.

Because I want the spare parts total for a contact to appear on the report in the same place as the vehicle total for that contact, I have put the subreport in the Group Footer section of the main report.

The report is still only showing the vehicle sales for contacts who have spare parts sales.  Interestingly, if I untick the box "Select data in subreport base on field:", it appears that I might be getting everything I need, however the layout is all wrong.  I get one spare parts customer followed by all the vehicle customers, then another spare parts customer followed again by all the vehicle customers.

I hope this helps and thanks in advance.
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