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

Store values for Table of Contents while a report prints

Status
Not open for further replies.

ontsjc

Technical User
May 17, 2000
113
Hi,

I'm creating what was suppose to be a fairly standard report with the report writer until I was asked to make a table of contents as well. I'm printing out a list of conentration values for chemicals found in a local environmental investigation. What I would like to do is each time a new chemical begins to print, somehow log the page number on which it starts. I have a little over two hundred chemicals and the report is almost 700 pages when printed so I really don't want to do this by hand. I currently have a group defined that starts each chemical on a seperate page, however it isn't as simple as counting how many records appear on a page since I have some other formatting which throws in location and the like of where the samples were taken that changes how many are printed. Any thoughts on storing page numbers when groups change or any such thing? I would greatly appreciate it.
 
There are several steps here.

First, to store the page numbers on the change of group, you need to write a function. The function will receive the group name (the name of the chemical) and the page number as parameters, and will write these out to a cursor or table (one record for each group).

Call the function from the group header. Pass it the name of the chemical (which you have in the report's underlying table) and the page number (which you obtain from _pageno).

When the report is finished, you will have a cursor that contains all the information you need for table of contents.

So, the next step is to create a separate report that uses that cursor to print the ToC. That should be completely straightforward.

Finally, immediately after you print the main report, print the ToC report - in the same printjob. To do that, add NOPAGEEJECT to the REPORT FORM command for the first report.

The only snag is that the ToC will appear at the end of the main report, rather than the beginning which is probably what you want. If that's important, we can find a way round that, but I suggest you start with the above first, and come back if you need to follow it up.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
You even have the chance to print the TOC in the same printjob in the sense of the same REPORT FORM, without using the NOPAGEEJECT clause and a TOC report, as reportlisteners offer the option to work in a two pass process via the Reportlistener.TwoPassProcess property and you can collect the _pageno data for the groups for reportlisterner.CurrentPass being 0 and then when the pass changes to CurrentPass being 1 print the TOC. That in itself could then also be printed as the first page, but of course this will shift all groups, so it's of course easier to append the TOC.

I have to admit I haven't done such a report, but I think just knowing these keywords TwoPassProcess and CurrentPass you'll find something in the help, in foxpros foundation classes, or via google.

Bye, Olaf.
 
Just a thought...

Under the condition where something new is found, you must have a flag to identify it, so add a conditional "print when" clause which calls an external function and passes the relevant information, along with _PAGENO, and returns a blank character string to print something, but nothing visibly.

In the alternative, and possibly a better suggestion, print the report to an HTML file and use a RegEx expression to grab the flagged items and their relative page number (searching for some unique printed item on new chemicals, such as "NEW CHEMICAL").

The second solution requires a relatively complex RegEx, but requires no changes to be made to the report. In addition you could use the HTML and write a small app to bring up that page of the report through a follow-on embedded within your VFP app through an ActiveX IE instance, which allows someone to review new items by bringing the reports up either internally in VFP, or in an external web browser, or even to move to a specific page in a generated PDF file, rather than sifting through printouts.

Lots of possibilities.

Best regards,
Rick C. Hodgin
 
You guys are great! Just for the record I took Mike Lewis's approach (not to discount the others) it worked like a charm. I can't tell you how happy this makes me. Thank you so much for your responses and ideas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top