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!

Printing Summary always at bottom of page

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Dear Team,

First of all, A Very Very Happy New Year to all of you guys!

I have a report form (an invoice) where I want to print the summary section, consisting of Invoice totals, a Terms & Conditions section (pure hard-coded text) and Delivery details, only at the last page. But, if I use Summary Band, it prints immediately after finishing the records of detail lines, ie may not always be at the bottom of page. If I use Page Footer with Print When as '_PAGENO == _PAGETOTAL' and 'Remove line if blank' checked, it prints only at the last page, but it leaves the footer spacing on every page. If my report runs into 5 pages, in each page (except last one) the height of footer section is always left blank.

I have already come across a post with a similar question, but didn't find a proper solution in that.

Any thoughts?

Thanks in advance,
Rajesh
 
In the report property optional bands you can choose whether the summary band prints right under the last detail and its footers or on a separate page, so if you want that, simply check the box at "Summary prints as new page":

separatesummary_q8a90k.png


Otherwise the pagefooter should be a solution, if you uncheck "constant band height" and only printwhen all elements of the footeer when the page is the last page, the footer band should not reserve blank space, as it will collapse when it's elements don't print.

Bye, Olaf.
 
Dear Olaf,

Thank you for your reply.

I don't want the Summary on a new page. I want the Summary to be always at the bottom of the page (like a page footer).
I had tried the settings you mentioned for page footer. But it didn't work. Even if the contents are not printed (when it is not the last page), it leaves the footer height spacing as it is. I believe, I checked and ensured for each and every element in the footer that they have '_pageno == _pagetotal' in their 'Print when' and the 'Remove if blank' is selected. Am I missing something else?

Thanks,
Rajesh
 
I checked and ensured for each and every element in the footer that they have '_pageno == _pagetotal' in their 'Print when' and the 'Remove if blank' is selected. Am I missing something else?

Yes. If you read Olaf's reply, you will see that he has given you that last step: remove the tick against "Constant band height".

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I tried a bit. It seems the foter only collapses "stretch with overflow" elements and still their unstretched size remains.

The only solution giving ou a chance to keep all space on every but the last page is to add enough empty lines, so the summary band will display at the page bottom.

Bye, Olaf.

 
Dear Olaf,

As you suggested, I managed to add blank lines and now I am getting what I wanted when tested over a few invoices with different number of items on it ranging from 2 items to 150 items per invoice.

After generating the final cursor for the invoice report, I determine the number of blank lines to be inserted, if required, as below.

lBlankLines = 23 - MOD(RECCOUNT(), 38)

where 38 is max number of lines on any page and 23 is max lines that can be accommodated in the last page in order to give room for my summary. Then I insert <lBlankLines> number of blank records in my cursor.

As far as I have seen, it produced desired output.
The only bad thing is that I have hard-coded the numbers in the report's Init method where I generate the cursor.

Thanks to Olaf and all others too,
Rajesh
 
The only bad thing is that I have hard-coded the numbers in the report's Init method where I generate the cursor.

I don't think there's anything terribly wrong with that. Although it's generally undesirable to hard-code this sort of value, in this case the number is very much tied in with the design of the invoice. If I faced the same problem, I would probably do the same as you.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Dear Mike,

Yes, it's closely tied up with the design.
If I want to make it dynamic, at least for now, I just don't know how to do that and it would be a nightmare if I try.

Rajesh
 
Well, I suppose one way of doing it dynamically would be something like this:

1. In the summary band of your invoice, create a Run Expression. Have the expression call a function that sets a public variable to the page number (_PAGENO).

2. Before you generate the cursor, do a dummy print of one invoice, that is, print it other than to a physical printer (e.g. to a file, which you can later delete; or to NULL [if that option is still supported]).

3. You now know the number of pages; it's in the variable from step 1. You also know how many records you have just printed. That should allow you to calculate the number of records per page.

4. Use that value when calculating how many blank records to generate in the cursor.

5. Print the invoices for real.

But I'm not seriously suggesting you do any of this. Hard-coding the relevant numbers is much easier, and perfectly acceptable, in my opinion.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top