Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple instances of the same subreport 1

Status
Not open for further replies.

ajthepoolman

Programmer
Nov 27, 2000
5
US
Hello all! I am very new to Crystal Reports. I am working on a report that has summary information on it. The report has about 10 columns that are nothing but numbers. The report requestor has asked for drilldowns on each of the numbers to show information about the number.

What I have done is create a subreport that has the information for the drilldown. Each of my drilldown areas will display the exact same information. I want to put multiple instances of my subreport on my main report and somehow distinguish which subreport was clicked on. Make sense?

I have put the same subreport on my report and noticed that the first report was rptSubReport.rpt. The second instance of the subreport is rptSubReport.rpt-01. So, Crystal will automatically index multiple subreports, which is great! I want to know how I can capture the index and pass it to my subreport so that my generic subreport knows which section it needs to run.

I know this is confusing. I wish there were a better way to explain it. In a nutshell I want to use the same subreport to display data related to the categories on my main report.

Thanks all!

Aj
 
Are you using Crystal's 'column' function? Or did you separately create the subreports and arrange them to be in columns?

If it is the latter, then Crystal would regard them as separate and you can individually change them in the 'Design' sections.

If it is columns, then someone else will need to advise you, since I have never used them.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I am not sure which one I am using. Here is the outline of the report:

Report Header -- I am supressing this
----------------------------
Page Header -- Report Title and such
----------------------------
Detail section --
Total # of Calls 5 <-- Drilldown here
Prep Families 8 <-- Drilldown here
Local Families 5 <-- Drilldown here
Out of State 3 <-- Drilldown here

----------------------------
Report Footer
----------------------------
Page Footer



OK, back to me. I want to use the same subreport on each of the drilldowns above, but pass a different value based on which line item they clicked on. For instance, if they click on Total # of Families I want to pass a 1 to the subreport. If they click on Prep Families, I want to pass a 2. And so on and so forth.

Is there a way to do this that you know of?

Thanks again!

Aj
 
What you are talking about is the equivalent of a subreport link. Are some of the fields in the detail section different results of the same field? If they are, you only need one subreport linked to the main report on that field. If they really are separate fields, then link each one on based on that field. In the main report, go to edit->edit subreport links and choose each subreport and set the link.

-LB
 
No, unfortunately the detail report is different.

Here is what I ended up doing. I created 11 differently named subreports. Linked them off of the one common field that they had. All of the subreports were then pointed to the same stored procedure. The stored procedure returned basically SELECT *. I then used the Record selection to sort my data.

Took all damn day to make the report, but it works!

I read about shared variables and global variables. I am wondering if I could of linked on those somehow. Being so new to this though I don't even know where to declare the variables at.

Thanks all!

Aj
 
In Crystal, there isn't a special place to set up variables, shared or otherwise. You place them in the print sections, and this is a typical way to do it.

To pass data back from a subreport, use a shared variable. Make a formula field in the subreport like

whileprintingrecords;
shared currencyvar WasSaved;
WasSaved:={#TotSaved};
WasSaved

To access it in the main report, create another formula field with

whileprintingrecords;
shared currencyvar WasSaved;
WasSaved

Note that the shared variable is only available in the section after the section which contains the subreport.

Dates and numbers can also be passed, and boolains too. You'd say datevar etc. in place of currencyvar.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
That is one of the biggest questions I have had thus far. Where do I declare and set variables?

After reading about shared variables, I figured that this is what I needed to make this work. But I couldn't figure out where to declare them. Are you saying that I have to create a formula field and then set the variables within that field? Do I have to put that field on my report somewhere? Or can it stay in the list of formula fields?

In thinking about all this though, I still have a hangup. Regardless of shared variables and such, I still need to know which subreport was clicked on so I can set that variable. For those of you who are familiar with Visual Basic, I need a click event on the subreport so I can manipulate my shared variables before the subreport gets called.

But regardless, I appreciate everyone's help with this. I have found enough of a solution to make it work.

Thanks!

Aj
 
For all variables, create a formula field and then set the variables within that field. And unless you put that field on your report somewhere, the variable will do nothing.

For shared variables, you need to place them in the subreport and main report, as I showed.

You can suppress the field, if you don't want anything to show visibly.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top