Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: formula to compare detail lines of two subreports Post Reply Post New Topic
Author Message
RHRII
Newbie
Newbie


Joined: 13 May 2009
Location: United States
Online Status: Offline
Posts: 3
Quote RHRII Replybullet Topic: formula to compare detail lines of two subreports
     Posted: 14 May 2009 at 8:43am

The report I'm working with has two subreports.  Both subreports have details listed.  I need to be able to compare a value in each of the detail lines in one subreport to a value in each of the detail lines in the other subreport.  For example, find the detail line in subreport A that has a date that matches a date in a detail line in subreport B.  Any advice would be greatly appreciated!

Thanks,

Robert

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 May 2009 at 6:39am
you can't...not the answer that you want.  Crystal reads the report and the data.  When it comes to a subreport, it stops processing the main report and processes the subreport completely, goes back to the main report and processes the next subreport completely, so there is no searching one subreport from another.
 
how you might get around this is to get rid of one of the subreports, by incorporating it into the main report, and have the remaining subreport tied to the what was the other subreport by some parameter (value).  Now you can pass in a value that the subreport can look for.
 
personally, I don't use subreports too often, they are a big hit to performance, as each subreport will hit the database again.  for your report with 2 subreports and 100 records in the main report, would be 201 hits to the database, and if the network is busy...  In many cases, I believe that, subreports are unnecessary.  I also use stored procedures to drive all my reports as there is much you can do in a stored proc to manipulate the data and get the data that you need already related that renders the need for a subreport moot.  That being said, every now and then I need a subreport, but I can count on 1 hand the number of subreports I have written in the past 4 years of report writing.
 
I don't think that I best report writer in the world, perhaps I am trying to be laziest, but from a performance stance and a complexity stance, it is way easier to maintain 1 report instead of 3, which are the subreports and the main.  whenever 1 changes, it will/can affect the other 2 in terms of layout and visual clarity.  Get the data once, get all the data that you need for any record in the report and return it to the report (stored procs do this) and this allows you to use your database to the utmost.  you paid for the sql server, harness its power.
HTH
IP IP Logged
RHRII
Newbie
Newbie


Joined: 13 May 2009
Location: United States
Online Status: Offline
Posts: 3
Quote RHRII Replybullet Posted: 15 May 2009 at 7:02am
HTH,
Thank you for your prompt response and the advice.  I will look into using some stored procedures.  Before I redo my report, can I pick your brain a little?  As the report stands now, would it be possible to use arrays to store the values from the detail lines and perform the calculations in the main report after the subreports have been processed?  I could use EvaluateAfter to control the formula processing order.  This is the only solution I could think of that might work without redoing the report.
 
Thanks again,
 
Robert
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 May 2009 at 10:34am
I'll be honest, I haven't done much with arrays...instead I have used formatted strings (basically because I am not sure how Crystal creates arrays and how large it would need to be)  I know that you can create a shared variable which is an array, so it should be possible to pass data back and forth that way.
 
If you filled the array in subreport1, it would be available at the time that subreport2 is being processed.  So from this, it might be possible for you to process between them.
 
good luck!
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