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!

Call subreports from a loop in main report

Status
Not open for further replies.

pvirsf

Technical User
Aug 30, 2004
35
US
Running CR 9 on Windows XP, PC. Does anyone know of a way to repeat the same subreport a dynamic number of times, from a loop in the main report, changing only variable(s) in the main report for each loop which are shared into the subreport, to yield different results from the subreport each time? The only way I am aware of is to insert the subreport into sections of the main report a pre-defined number of times.

 
This may help: faq149-3226

Otherwise, explain the WHY rather than just the WHAT. Perhaps a better approach can then be identified.

Cheers,
- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thks for the tip Ido. My situation is slightly different.

Client has fields F1, F2, F3, F4 on each record in a table and they wish to group on them. The number of groups is determined by the number of distinct values appearing in any field F1 thru F4 anywhere in the data base table. E.G. if aa, bb,cc, dd, are values that appear, the grouping for aa woould include only records where aa appears in F1, or F2, or F3, or F4.

Currently my approach is to have a main report with 20 sections, each containing the same subreport that reports for one of the groupings and suppresses all other records.
This works and if there are only 7 distinct values, the sections for 8-20 are simply suppressed. Crude, but it works. Just wondered if there was a better way???

 
One option is to simply create a UNION ALL query:

SELECT .... ,F1 As MyField From MyTable
UNION ALL
SELECT .... ,F2 From MyTable
UNION ALL
SELECT .... ,F3 From MyTable
UNION ALL
SELECT .... ,F4 From MyTable

Now, simply group on MyField

Cheers,
- Ido


Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top