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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call another report from a report - not using subreports

Status
Not open for further replies.

rogercruz

Programmer
Jul 15, 2003
6
US
Here is my challenge (CR v8.5):

I am working on an Order Acknowlegement report. We need the same report to print twice... the first being a report marked "CUSTOMER COPY" while the second is marked "SALES COPY". I want to avoid having to run the report twice for the two different versions.

I first tried inserting a 'Sales Copy' subreport in the report header, but because subreports do not have Page Header/Footer sections, I would lose some information on multiple-paged reports - when I put my Page Footer data in the Group Footer as a workaround, that data only printed on the last page of the subreport.

Can I just have two seperate reports where the first "CUSTOMER COPY" report calls/passes parameters to the second "SALES COPY" report so that when I print the first, the second is printed as well? Or can anyone offer another creative solution? Thank you.
 
There are several possible solutions for this but here's a "cool" one:

Add a table with a single numeric column ("Which_One").
Insert two records (1 and 2 in the "Which_One" column).

Add the table to your report without any join condition.
This would result in every record being duplicated (once with a join to the 1st record ("Which_One" = 1) and once to the nnd record ("Which_One" = 2).

Use "Which_One" in a formula to decide which "copy" it is.

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thanks Ido,

Unfortunately, I could not get this to work on CR 8.5. I added the table to my report without any join conditio, and, Crystal complained about "multiple starting points" not being supported. I continued anyway, and CR does not perform the join as expected; the data is only printed once. Also, when I add the "Which_One" field to my details section, it shows as 0 (even though only the values 1 & 2 are defined in the table).

Do you have any further suggestions? Right now, I'm open to anything! Thank you for your time.
 
You can achieve the same result by taking the existing SQL and doing a UNION ALL with itself, using an additoinal column:
---------------------------------------------------
SELECT ...... , "Customer Copy" as Copy_Version
FROM ...
WHERE ....
UNION ALL
SELECT ...... , "Sales Copy"
FROM ...
WHERE ....
---------------------------------------------------

hth,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Why not just add a subreport for one of the copies, ensuring that it uses the same amount of page space as the version in the main report, and then conditionally change the page footer information in the main report, as in:

if pagenumber <= totalpagecount/2 then &quot;Sales Copy&quot; else
&quot;Customer Copy&quot;

-LB

 
But you'd still end up losing whatever code was in the page header/footer section, once the subreport kicked in.

I would support IdoMillet's approach, or making a copy of the report, and linking to it with a hyperlink from the original report. As the parameters are passed from original report to copy, one represents the sales copy and the other the customer.

Naith
 
Naith--

What &quot;code&quot; in the page footer/header section would you lose?

-LB
 
RogerCruz said:

&quot;I first tried inserting a 'Sales Copy' subreport in the report header, but because subreports do not have Page Header/Footer sections, I would lose some information on multiple-paged reports...&quot;

by 'code', I meant fields and formulas. Sorry if this wasn't clear.

Subreports do not have page headers or footers, hence any fields or formulas placed in either of these sections would not be transferred to the subreport.

Naith
 
Naith--

I was suggesting that he could use the main report page footer (and page header for that matter). Let's say he is grouping on customer ID. If he creates the main report and then creates the same report as a subreport, and links on customer ID, he can place the subreport in the group (ID) footer. If he suppresses everything but the group header and details in the subreport, he can use the main report page header and footers for both sales and customer copies.

In format section, &quot;new page before&quot; would be set on Group 1 header for the main report (with the condition &quot;not onfirstrecord&quot;) and &quot;new page before&quot; would be also be set for the group (ID) footer in the main report. Also &quot;reset pagenumber after&quot; should be set for the group (ID) footer.

Then this formula could be added to the page footer of the main report:

if pagenumber <= totalpagecount/2 then &quot;Sales Copy - Page No: &quot;+ totext(pagenumber,0,&quot;&quot;) else
&quot;Customer Copy - Page No: &quot; + totext(pagenumber - totalpagecount/2,0,&quot;&quot;)

Now each customer ID will have a sales copy of 1 or more pages and a customer copy with the same number of pages, all with matching page numbers.

If there were other information in the page footer or header that was specific to the customer, then that would have to be built into the main report, of course. It would help to know what that information might be...

-LB
 
LB,

I fixed up my subreport as you described in your last post, and my report is working as I wanted it to... I just need to add formulas to edit the page numbers; otherwise, it's perfect.

Thanks to everyone who participated in this post!

Roger
 
After the subreport worked as needed, here is how I manipulated the page numbers and copy label so the printouts looked like two reports being printed...

I added the following Formula fields to the report:

&quot;NewPage&quot;
IF PageNumber <= (TotalPageCount/2)THEN PageNumber
ELSE (PageNumber - TotalPageCount/2)
&quot;NewPageCount&quot;
(TotalPageCount/2)
&quot;CopyLabel&quot;
IF (PageNumber <= (TotalPageCount/2)) THEN &quot;CUSTOMER COPY&quot;
ELSE &quot;SALES COPY&quot;

For the page number, I added a text object which read, &quot;Page {@NewPage} of {@NewPageCount}&quot;. I just added the {@CopyLabel} formula field to the bottom of my report so that when printed, we would know which copy was which.

Again, thanks to everyone for participating!

Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top