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

Delete report based on number of pages

Status
Not open for further replies.

dswitzer

Technical User
Aug 2, 2002
298
US
Can anyone think of a way (CRXI) to delete a report based on the number of pages?

For example, I have a mail merge that brings in various subreports and shows different detail depending on the data. So my single report may have 6 pages for client#1 and 9 pages for client#2 -- all in the same document (so I can just print them all at once). If I only wanted to keep those that had 10 pages (or only run those with 10 pages)--is there a way to do that?

I guess I could set up a shared variable in the beginning to count pages and increment that variable with each page added and then see the total at the bottom of the client output (easy to say but I'm not too sure how to execute). If I could get that to work, how would I go about deciding whether to show the group header/detail/footers if the ending pages <>10 ?

Thanks.

Dave
 
If you reset the page number after the group footer, assuming you have a group on client, then you should be able to use something like:

totalpagecount < 10

...in the section expert->group header/details/group footer->suppress->x+2.

-LB

 
Wow. Yep - I can get a pgCt to count the number of pages.

However, say I have a 14 pager (I write out my pgCt variable on the last page and it is 14) and I set the
section expert->group header->suppress->x+2 to suppress unless it is 14 pages (I like to work in increments as I learn so I am not messing with details/footer suppression until I get this section working)

Code:
whileprintingrecords;
shared booleanvar suppress;
shared numbervar pgCt;
if pgCt<14 then suppress:=true
else suppress:=false

When I add in the suppression code, it suppresses the group header every time -- even my known 14 pager has the header suppressed -- and now the pgCt I print at the end =13 -- so it suppressed it's own counter??

Must be in the order of operations....any ideas?

Thanks.
Dave
 
My mistake - but it is still not working....

group header1:
(I know this is one page in length and insert page after)
Code:
whileprintingrecords;
shared numbervar pgCt:=1;

group header2:
(this is variable in length - could be 1-4 pages -- it is my data headers so I know when it prints a new page is born)
Code:
whileprintingrecords;
shared numbervar pgCt:=pgCt+1;

group footer1:
(this will be supressed if certain conditions are not met and it is a static 2 page report)
Code:
whileprintingrecords;
shared numbervar pgCt:=pgCt+2;
There are more group footers with the same incremental code.


So, when I print out pgCt -- it gives me the correct number for each client. But how do I now get group header1 to be suppressed, for example, if the pgCt for this client =13 then suppress the header?

I have this in the group header1 conditional suppression section:
Code:
whileprintingrecords;
shared booleanvar suppress;
shared numbervar pgCt;
if pgCt=13 then suppress:=true
else suppress:=false

Yet nothing is suppressed. Ideas?

When I change the code in the group header1 conditional suppression section to:
Code:
whileprintingrecords;
shared booleanvar suppress;
shared numbervar pgCt;
if pgCt=1 then suppress:=true
else suppress:=false

Then group header1 is suppressed every time. If you refer back to my first block of code, inside the group header1 I reset the pgCt variable to 1 every time. So, I am deducing that the pgCt in the group header1 conditional suppression section is the "immediate" pgCt -- not the "final" pgCt... How do I fix this?


Thanks.
Dave

 
I wasn't suggesting that you use a variable, since it is essentially a running total which won't be available at the right times. I was suggesting you use the "special field" totalpagecount which is available up front. So you just need to use the section expert to reset the page number after each group, and then go into each of the group header, detail and group footer sections->suppress->x+2 and enter:

totalpagecount < 10 //if you want only groups with 10 or more pages to print.

-LB
 
Thanks lbass - I appreciate your time. That variable was all my idea...I understand your advice now -- totally makes sense.

I got rid of all the stuff I was doing before and am focused on totalpagecount -- but am still struggling.

I am printing out totalpagecount on groupheader1 and it is correct -- if the client report has 10 pages, totalpagecount =10,etc...

However, when I add this code to conditionally suppress any section:
Code:
whileprintingrecords;
shared booleanvar suppress;
if totalpagecount=10 then suppress:=true
else suppress:=false
This should result in supression of the groupheader1 for any client with 10 pages -- my second client in sequence has 12 pages so that population<>10 does exist. But no matter how I change that code or where I put it -- it suppresses the section for everyone. If I put that conditional suppression on all my sections -- I get a blank report.

I'm sure I am missing something fundamental here...

 
I'm sorry, but there is a problem with my suggestion. It seems to work until a group appears that doesn't meet the criterion, and then it stops working. If the order of the groups doesn't matter, you could do a topN sort based on the count of a recurring field, ascending, and then use the suppression formula so that it suppressed groups with a totalpagecount > n. I can't guarantee this would work consistently.

The other approach you might take is to insert a count on a recurring field, and then limit your groups to groups which fall into certain ranges of records. Instead of using suppression, I would then go to report->selection formula->GROUP and enter something like:

count({table.field},{table.groupfield}) in 450 to 500

This would not be exact because of group sections on the page. Although you could determine the exact line count per page by using a variable which would count all sections, the problem is that it would not be available for group selection or for suppression of all sections.

-LB
 
I appreciate your effort. Knowing what I know now I probably will attempt to set it up differently next time.

I ended up segmenting manually into similar estimated lengths and then manually searching for totalpagenumber different than what I expected and then resegmenting. Painful and tedious but it is done.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top