Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Restricting results when combining tables Post Reply Post New Topic
Author Message
bowja
Newbie
Newbie
Avatar

Joined: 07 Dec 2009
Location: Australia
Online Status: Offline
Posts: 31
Quote bowja Replybullet Topic: Restricting results when combining tables
     Posted: 10 Dec 2009 at 12:51am
My report uses primarily fields from Table 1. I want to add two fields to the report from a second table (Table 2) without changing the resulting number of lines in the report.

There are a number types of data in the field but I am only interested in two. Basically I would like Field 1 to show “Order Taken” if this data exists for the result (case no.) in the current line. If “Order Taken” does not exist I would like the field to remain blank. For Field 2 I would like it to show “Order Confirmed” if this exists or blank if not.

Currently when I add the fields in it adds in a line to the report for every type of data i.e a line for “Order Taken”, “Order Confirmed”, “Phone”, “Visit”.

Table 1 e.g.

Order     Order Date     Start Date     Finish Date     Paid
091845     1/12/2009     3/12/2009     22/03/2010     True
080849     9/06/2009     5/07/2009     5/12/2009     False
096879     1/01/2008     3/03/2008     3/12/2009     True

Table 2

Order     Comment Date     Description     Comment

091845     1/12/2009     Order Taken     Jenni happy with
091845     2/12/2009     Phone     Left message for Ron…..
091845     3/12/2009     Order Confirmed     Spoke to Jenni……
080849     9/06/2009     Visit     Meet with Joe…..
080849     11/06/2009     Order Taken     Happy to go ahea
080849     13/06/2009     Quote     234
080849     12/08/2009     Order Confirmed     Jeff
080849     15/09/2009     Debtor     Finance dept needs….
080849     15/11/2009     Payment     Balance owing paid….
096879     01/01/2008     Phone     Introduced….
096879     03/12/2009     Update     Closed order.

Current Outcome when combined
NB: Order Number/row is duplicated for each resulting data type for “Description”

Order     Order Date     Start Date     Finish Date     Paid     Description

091845     1/12/2009     3/12/2009     22/03/2010     True     Order Taken
091845     1/12/2009     3/12/2009     22/03/2010     True     Phone
091845     1/12/2009     3/12/2009     22/03/2010     True     Order Confirmed
080849     9/06/2009     5/07/2009     5/12/2009     False     Visit
080849     9/06/2009     5/07/2009     5/12/2009     False     Order Taken
080849     9/06/2009     5/07/2009     5/12/2009     False     Quote
080849     9/06/2009     5/07/2009     5/12/2009     False     Order Confirmed
080849     9/06/2009     5/07/2009     5/12/2009     False     Debtor
080849     9/06/2009     5/07/2009     5/12/2009     False     Payment
096879     1/01/2008     3/03/2008     3/12/2009     True     Phone
096879     1/01/2008     3/03/2008     3/12/2009     True     Update


Desired Outcome
NB: Only one line per order number I have used Description 1 to say if their was an Order Taken comment and Description 2 to say if their was and order confirmed comment. The last row is blank because Table 2 had no comments with the descriptions Order Taken or Order Confirmed for the record with order no. 096879
Order      Order Date     Start Date     Finish Date     Paid     Description 1     Description 2
091845     1/12/2009     3/12/2009     22/03/2010     True     Order Taken     Order Confirmed
080849     9/06/2009     5/07/2009     5/12/2009     False     Order Taken     Order Confirmed
096879     1/01/2008     3/03/2008     3/12/2009     True          
If you think you can or think you can't you are right - Paraphrased quote Henry Ford
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Dec 2009 at 6:44am

Not knowing the data, it appears that you can move the fields to the group footer (this will give you only 1 row per group(based on OrderNo)).

I would create a formula that has shared variables, in this case boolean would work, and place it on a detail line that would look something like:
shared booleanvar Taken;
shared booleanvar Confirmed;
if left({table.field},11) = 'Order Taken' then Taken := true;
if left({table.field},15) = 'Order Confirmed' then Confirmed := true;
 
""//hide the output.
 
suppress the detail section as you don't want to see them anymore
 
Now you will need to reset the variables to false in the group header (another formula)
 
In the report, I would put 2 text boxes that each say the desired verbiage. On there General tab, Suppress, enter something like:
shared booleanvar Taken; //for example, both will look similar
Not Taken
 
that will 'hide' the text box if the variable is not set.
 
That should be all you need.
 
HTH
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