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!

Combining two listings into a single report

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I am familiar with designing a .frx report which is based on a single table or cursor, perhaps also using fields from related tables. I would now like to produce a single report which has two sections in it, each one being a listing of the contents of a cursor or table, perhaps with totals. The two sections of the report are not necessarily related to each other.

For example, two cursors have been generated :

Cursor tCust (tCode C(4), tName C(30), tBalance N(10,2))
Cursor tProduct (tProdcode C(16), tQty N(4), tCost N(8,2))

I would like to produce a single report, where the first page says :

Code:
     Debtors

Account   Name                                  Balance
-------   ----------------------------       ----------
A12       John Smith                             123.00
F18       General Trading Co                     987.00
                                              ---------
                Total debtors                   1110.00

and the second page shows

Code:
    Stock Value

Product                Stock         Cost             Value
----------          --------        -----          --------
7123                       5        12.50             62.50
7705                       1         8.00              8.00
                                                    -------
                        Total stock value             70.50

I understand that it may be possible by designing a banded report. I am not familiar with these, but if that is the way to go, if anyone has a worked example, I would, as always, be grateful.
 
Much easier is to chain two reports in that case. You can target a different alias at each detail band, but it doesn't make much sense for totally unrelated data, does it? You mainly use optional bands, when you have a relation between the standard detail band and its report driving table and further bands.

That said the property of interest is a property of the new detail band you get at when you right click on the bar labelled "Detail2" and go into the properties dialog of the detail band. There you can set how the band behaves (eg starting at a new page or not) and mainly define it's target alias expression. In your case this would be "tProduct", including the double quotation marks. Click help in the property dialog to get the explanation of the target alias expression.

If you really want to go that route you don't have the chance to use any other alias simply by selecting it before you start the report. The currently selected alias and it's filter or the REPORT FORM FOR clause will only drive the main detail band (assumed you don't work with private data session reports). So you lose control. You can put the alias name inside a variable and set the target alias expression to that variable name to make it more dynamic again, but what speaks against chaining reports? That in itself is even dynamic in the aspect of which reports you chain.

What really is the advantage to put such reports into one FRX? If you ask me you only introduce a maintenance hurdle ("Where was that stock value report?") without gaining anything valuable.

Bye, Olaf.
 
I agree with Olaf. Unless you have a special reason for combining them into a single report, I would make them into two separate reports. You can chain them together into a single print job, which might be useful, for example if the user might "print" the reports to PDF and wants them to be in the same file.

To chain two (or more) reports together, include [tt]NOPAGEEJECT[/tt] in the each [tt]REPORT FORM[/tt] command except the last. (This doesn't necessarily mean that the reports will be printed on the same page.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you. At present the code is effectively :

Code:
   SELECT tCust
   REPORT FORM repCust TO PRINTER PROMPT NOCONSOLE NOPAGEEJECT
   SELECT tProduct
   REPORT FORM repProd TO PRINTER NOCONSOLE

This produces a report from the two listings as a single document, which is good. There is a page break after the first listing (produced from repcust.frx).

As an enhancement, is there a way of suppressing this page break? The second listing may be very short, perhaps a few lines indicating notes to the first report which have been accumulated in the second cursor. It would be nice to add it to the foot of the repcust report, if there is room.
 
I think we had this discussion about the literal meaning of NOPAGEEJECT earlier on here at tek-tips within the last few months and we came to no conclusion when or when not the page eject happens and whether it's caused by the first or secondary report. You do have some settings to start at a new page or not even in standard detail bands, not only in optional bands. Look into the repProd report detail band properties. What is set there? Is "Start on new page" checked or unchecked?

Bye, Olaf.



 
Andrew, if the second report is indeed just "a few lines indicating notes to the first report", can you create the entire text in a memory variable? If so, you could add a field to the summary band (of the first report), and set its expression to the memory variable in question.

You can display multiple lines of text in this way, with as much data as necessary, but of course it won't work so well if the text contains multiple columns that will need to be aligned.

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you both. In fact after I wrote the last note I found the discussion to which you referred, in the matter of NOPAGEEJECT.

But at least the main result (of combining the listings into a single report) can be done. Grateful for that. Andrew
 
You might just need to set page header/footer to both have zero height. Just a guess without testing.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top