Solved

Crystal reports loop question

Posted on 2011-02-17
3
443 Views
Last Modified: 2012-05-11
I have a report that has a sub report that does some processing.  The parameter to the sub report is a year.  I want to call the sub report for a range of years.  This is provided by the user as a parameter.

So the user may enter a range of 2007 to 2010.  So then i want to call the sub report for the years 2007, 2008, 2009, 2010.  Another time a different range would be entered.

Is this possible?  The main report does not have any "data" and no database connection of its own... i just would like to somehow use the parameter range to call the sub report for each value in the range.

Really its just a for loop... would be great if i could put the sub report in the details section and then execute it for the supplied range.
 
0
Comment
Question by:soozh
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 34915045
If you're dealing with a limited number of values, you could create X number of detail sections, put a copy of the subreport in each section, and pass each copy a different value from your range.  You could use a suppression formula for the sections to suppress the subreports that you don't need (because the range doesn't include that many values).

 If you don't want to limit the possible number of values like that, you could set the main report to read something (an Excel file or a simple text file or whatever) and have the subreport executed once for each record, passing it a different value from your range each time.

 James
0
 

Author Comment

by:soozh
ID: 34915184
thanks.. both are good solutions in what CR offers.  

any other solutions?
0
 
LVL 34

Expert Comment

by:James0628
ID: 34924469
Nothing really springs to mind, as far as executing the subreport for each year goes.  You can't execute a subreport in a loop or anything like that.

 However, maybe there are other ways to handle this.

 The subreport could accept a range of years and run for all of those years.  If it groups on the year, you can basically get a separate report for each year (each year starts on a new page, etc.).

 For that matter, if the main report doesn't contain anything but this one subreport, do you really need the subreport at all?  Maybe you could have the main report produce a report for the range of years, grouped on the year, and forget the subreport.

 James
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now