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

Detecting a page break in sub-reports

Status
Not open for further replies.

baaxah

Technical User
Apr 26, 2010
7
FR
Hello,

I'm working with Crystal 9 and I can't find how to detect a page break into a sub-report. The only constraint I have is that this sub-report have to be placed in a footer section.

What I'm looking for :

TITLE
please see next page

------ ------------Page break ------------------------
TITLE
text
text

Of course, the sentence "please see next page" and the second title have to be removed in case there is no page break.

So, I've been trying with different formulas, using shared vars to suppress a section with the sentence "please...", but I couldn't pull this off. Does anyone have an idea ?

Thanks for your time,
Regards

Ps: The idea with shared vars was to get the page number before and after the sub-report, but when I import these vars in the sub-report they are somehow recalculated.
 
Sub Reports are an object and as such have no concept as to where they are in report. However, you can trick them with fake page header.

In Sub Report create formula

@FakePageHeader

whilereadingrecords;
""

Group on this formula and set options to repeat GH on new page.

You can then use the GH and GF to hold titles and text as required.

Ian
 
Hello Ian,

Thanks for your quick answer ! I used your fake formula and it works pretty well ;) The GH is displayed in every page, so that's perfect. Perhaps, there is still something I couldn't do : add the sentence "please see next page" when these is a page breaks.

Example without a page break

TITLE
this is text to be displayed
this is text to be displayed

Example with a page break

TITLE
please see next page

.........................................
page break
..........................................

TITLE (thanks to the fake formula)
this is text to be displayed
this is text to be displayed

So, right now I'm able to repeat the GH in each page, but I need a trick to suppress or not the sentence "please see next page". What condition can I use to suppress a GHb for example ?

Thanks for your time !
 
Not really sure what you are trying to do.

What causes the page break?

You might be able to combine some logic, ie if its because there are too many records, try to use a formula that looks at record count to display text or not.


If count(uniquefield) >100 then "See next page" else "This text to be displayed"

Ian
 
Ian,

The page break it's caused by Inet. I'll try to explain what I need more carefully.

In my report, I have a lot of information and at the end, I have a section named Remarks. In this section I have to display a text, always the same, but the formatting may change depending on the page break.

EXAMPLE 1: (no problem here)
--------------------Page X----------------------------
info
info
info

Remarks

ljfldksjfklsdjfklsdjfkljsdklfjsdklfjsdklfjsdklfjklsdj
djfsdklfjsdkljfklsdjfklsdjfklsdjfkl
jdfljdsklfjskldfjsdkl




EXAMPLE 2:
--------------------Page X----------------------------
info
.
.
.
.
.

Remarks

please see next page

--------------------Page X+1----------------------------
Remarks

ljfldksjfklsdjfklsdjfkljsdklfjsdklfjsdklfjsdklfjklsdj
djfsdklfjsdkljfklsdjfklsdjfklsdjfkl
jdfljdsklfjskldfjsdkl

In this example, the text can't fit in the same page , so I have to create a new title in the next page (thanks to the fake formula) but I also have to add the sentence please see next page. It is mandatory for me to keep the first title (Remarks) if it can fit in page X. I agree that it would be easier to move down the whole section but customer is always right ;)
 
Sorry for silence. Struggling with this one as can not see how you can test for a page break before it is forced by over flow of data.

Need to think some more, hopefully some one else may have a neat solution.

Ian
 
Thanks Ian, I've been working on it for 2 days and I couldn't find a solution...I'm not expert on crystal but I think there is no an easy way...

Well, if you have any idea it would be really useful !!!

Thank you very much for your time

Regards,
 
Can you clarify whether the remarks are the only thing in the subreport? If so, then, format the subreport object to "keep object together" (format subreport->common tab->keep object together) and place it in a main report group footer_b section. In main report group footer_a, use a formula like this:

if totalpagecount > 1 and
pagenumber = 1 then
"Remarks: "+chr(13)+
"Please see next page"

In group footer_b, add this formula:

if totalpagecount > 1 and
pagenumber > 1 then
"Remarks"

In the same group footer_b, add the subreport just below the formula.

Make sure that the higher order group footer (above GFa) in the section expert is NOT formatted to "keep together".

If you are using groups, you should format the group footer to "reset page number after".

If you are not using groups, then in the above where I have referenced group footers, you should use "report footer" instead.

-LB
 
Hello LB,

First of all, yes, in the sub-report I only have the remarks (text).
Second of all, I'm not able to know in which page the remarks will appear. You assumed that it was in the first page but it is not the case, this document may have 2 or 100 pages actually.

Besides, is there a way to know how many lines there is still in the page ? May be I can evaluate before if I will need another page or not...what do you think ?

Sincerely, thanks for your time
Rgds,
 
Can you clarify a few things.

Why are you using a subreport for the remarks?

What section is the subreport in--is it a group footer or a report footer?

Is the remarks section always the last element in the group or report?

Are you saying that the Remarks section could start near the top of the page potentially?

-LB
 
Hello,

"Why are you using a subreport for the remarks?" [/color red]Well, since I needed to repeat the title if the page changes, I decided to use the "fake formula" from Ian.

"What section is the subreport in--is it a group footer or a report footer?"[/color red]
The subreport used to display the remarks is a report footer. This is the end of the document, and I already used the headers and details. Besides, this sections has to appear once in the document, at the end, so a report footer seems to be a good option (event if I don't have the choice )

"Is the remarks section always the last element in the group or report?"[/color red]
Well, actually, after the remarks I have to display a legal notice, buy in this case I'm not worried about page breaks or anything, it's just a classic display at the footer.


"Are you saying that the Remarks section could start near the top of the page potentially?"[/color red]
Yes, exactly. My document is a list of reservations for one or several customers, so before the remarks I could have 1 o 10 pages, and the remarks section starts just below the last reservation. So it could be at the top of the page, in the middle, or almost at the end (the troubling case ).


For the moment I'm placing the sentence "please see next page" just below the group header in the sub-report (GHb) and I'm trying to find a good condition to suppress it when there is no change of page...but it's not working
 
You did not answer LB's question
"Why are you using a subreport for the remarks?"

Can you access the Remarks data directly in main report?

Can you start the Remarks on a new page? ie place a new page before on the section holding the SubReport.

Ian
 
You did not answer LB's question
"Why are you using a subreport for the remarks?" [/color red]
I did answer this question, but I guess I was not clear enough.

I'm at the end of the document and I need to create a title (remarks) with a text below.
Without thinking about a page break, of course I could use a report footer, and if the text doesn't fit the whole footer section moves down...there is no problem here , BUT, it is mandatory for me in case of page break :

1/ To have the same title twice, one on page X and the other in the page x+1 with the text. So, Ian's tip about the fake formula in a subreport solve this issue. (that's way I routed to a subreport solution for the moment)

2/ Just below the first title on page X I have to add "please see next page", and that is what I'm looking for right now.

Here is the schema I posted above :

EXAMPLE 2:
--------------------Page X----------------------------
. reservation 1
.
. reservation 10
.
. etc
.
.
Remarks => first title, as the text doesn't fit the text moves down[/color red]

please see next page => tell the customer to keep reading [/color red]

--------------------Page X+1----------------------------
Remarks before add the text I repeat the title[/color red]

ljfldksjfklsdjfklsdjfkljsdklfjsdklfjsdklfjsdklfjklsdj
djfsdklfjsdkljfklsdjfklsdjfklsdjfkl
jdfljdsklfjskldfjsdkl
[/color blue]

About the other questions, the remarks it's just text, so yes, I can get it in main report. The remark section must always start after the last reservation

Regards,
 
Sounds like you do not really need a subreport just two text boxes which are checked as keep together.

Using a variable you can count records on a page, then if count is greater than a certain amount show Please see next page text and if not then your Remarks text.

@Reset
//Place this in page header and suppress
whileprintingrecords;

global numbervar recno:=0

@countrec

//Place this in details and suppress
whileprintingrecords;

global numbervar recno:=recno+1

Then in conditional suprression of Please see next page text box


whileprintingrecords;

global numbervar recno > x
//where x is number of records which will cause a page break with your remarks text.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top