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

How do I combine two reports?

Status
Not open for further replies.

JohnInDC

Programmer
Joined
Aug 26, 2005
Messages
20
Location
US

What is the easiest/best way to combine two reports?

They are independent reports with different formats and pulling data from different tables.

I am assuming there's a way to combine them.

I'd like to either append the second report to the end of the first report or have them in different tabs on the report form.

I'm using Crystal Reports 9 with Visual Basic 6.0.

Thanks in advance for your help.

John
 
INSERT one as a subreport in the report footer of the other.
Ignore prompts for linking fields.
 
Thanks lupins46.

I followed your directions, and inserted it as a subreport in the footer of the parent report.

Now I need to figure out how to bind the data to the subreport in my Visual Basic code.

Do I instantiate a report object for the second report? Or do I use .OpenSubreport (or something else) with the parent report object?

One report is called TowerReport. The one I want appended to TowerReport is called SatelliteReport. I have DSRs for both of them, dsrTowerReport and dsrSatelliteReport.

Right now, SatelliteReport has its own form that contains a CRViewer. The VB code in the form instantiates a dsrSatelliteReport object, queries the database, binds the record set to the report object with .Database.SetDataSource, and displays it in the form with the CRViewer.

The TowerReport form basically does the same thing with a different data source and dsrTowerReport.

I need to put code into the tower report form to query the satellite database and bind the record set to the dsrTowerReport instead of the dsrSatelliteReport. Is that right? Or, do I bind the record set to a dsrSatelliteReport and then bind that to the dsrTowerReport object??? If so, how do I do that?

I'm very new to Crystal Reports, and frankly VB isn't my best language either...

Thanks again for your help.

JT
 
OK, I figured out the data binding issue. I bind the subreport to the parent report as a subreport. (Duh!)

However, the satellite report has it's own report header and page header, so just putting it in the footer of the tower report is not quite what I wanted. The tower report is several pages, and the satellite report is several pages, so some strange things are happening.

The last half page of the tower report is being displayed at the top of all three of the satellite report pages, and the satellite report page header is only displayed at the start of the satellite subreport section (tower report footer).

Now that I think of it, this is actually the opposite of what I should have expected. That is, it seems the entire satellite subreport footer should be at the bottom of each tower report page...

What I need is for the two reports to be separated better, with their own report headers and page headers appearing on the appropriate pages.

How do I put the satellite report in a tab on the tower report? Can I do that?

Thanks,
JT
 
... Oh, I guess as a _report_ footer it doesn't appear on every page.

JT
 
It doesn't sound like you have the subreport in the report footer. If you are using the report footer in the main report, then insert a report_footer_b and place the subreport there. Then go to the section expert->report footer_a->check "new page after" so the subreport appears on its own page. If you want to suppress the main report page header on the subreport pages (but want them to show on the main report report footer_a pages), create two formulas:

//{@false} to be placed in the report header:
whileprintingrecords;
booleanvar flag := false;

//{@true} to be placed in report footer_b section:
whileprintingrecords;
booleanvar flag := true;

Then go to the section expert->page header->suppress->x+2 and enter:

whileprintingrecords;
booleanvar flag;
flag = true //note no colon

To get a recurring page header within the subreport, create a formula in the subreport that is true for all records, e.g.:

whilereadingrecords;
1

Then insert a group on this and format it to "repeat page header on each page". Remove the groupname and place your page header fields in the group header.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top