Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: CR9: Suppress a GrpHeader when detail on next page Post Reply Post New Topic
Author Message
jackyhui
Newbie
Newbie


Joined: 29 Jun 2009
Online Status: Offline
Posts: 3
Quote jackyhui Replybullet Topic: CR9: Suppress a GrpHeader when detail on next page
     Posted: 29 Jun 2009 at 8:54pm

I have a report structured as follow

Page Header
   --------Linked SubReport--------
   GroupHeader a (suppressed)
         GroupHeader b (Reprint Group Header on each page)
               GroupHeader c (Reprint Group Header on each page)
                     details
               GroupFooter c (suppressed)
         GroupFooter b (suppressed)
   GroupFooter a (suppressed)
   --------Linked SubReport--------
Page Footer

 

The Subreport may span several pages and sometimes GroupHeader b or c may appear at the end of each page and the corresponding details on the next page. This is what I do not want. Is it possible to suppress the GroupHeader b or c when the details actually start on the next page where the headers will be reprinted. If the details follow the Groupheader b or c immediately on the same page, then suppression is not needed. I cannot figure out how can I do it if possible in Crystal Reports 9.


Any suggestion?


Jacky Hui



Edited by jackyhui - 29 Jun 2009 at 8:56pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Jun 2009 at 7:03am
best suggestion is right click on the group in the subreport, go to the options tab and click 'Keep group together'.  this will force a page break and keep the group info/headers together.  Otherwise you will need to count the line/position of the line being printed and if it is greater than some value force a pagebreak.  You can force a page break by going to the section expert and in the formula button for New Page Before, entering you criteria.
 
You can have the subreport and the main report 'talk' to one another through shared variables. You would need to reset the variable every page, and would need to increment it every section displayed.
 
though if your entire report is basically a subreport, I would move the subreport into the main report (better performance because there are fewer hits to the database)
 
I don't know if all of these options are available in 9, but I suspect that they are.
 
HTH
IP IP Logged
jackyhui
Newbie
Newbie


Joined: 29 Jun 2009
Online Status: Offline
Posts: 3
Quote jackyhui Replybullet Posted: 30 Jun 2009 at 8:09am
keep group together is not an option as the same problem will escalate to groupheader b from c, or even to groupheader a from b.
 
How to count the number of lines printed? Can you point me to some functions or documentations?
 
One difficulty is that some fields in the detail sections are allowed to span multiple lines if the text is longer than the width set (Can Grow set to yes).
 
Can I somehow determine the action height of the field printed on the report? If yes, I can accumulate this height and set the page break in my code and hence suppress any redundant GroupHeader.
 
Any suggestion?


Edited by jackyhui - 30 Jun 2009 at 9:05am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Jun 2009 at 10:19am

Can grow, hmmm... that will throw some more monkeys into the mix.

What I would suggest is a series of formulas that update 1 shared variable, and this variable would be checked in the new page before formula.  Unfortunately, there isn't a way that I know of to check the actual height of an item at run time.
 
Each section that is displayed would get a formula, luckily most don't size.  The generic formula would be something like:
shared numbervar printLength := printLength + (sectionHeight);
"" // hides the calculation
 
For the page header section, it would just assign the height of the section like:
shared numbervar printLength := (sectionHeight);
"" // hides the calculation
 
Hopefully, not too many fields are set to can grow, but I would probably attack it like this:
shared numbervar pageLength;
local numbervar itemHeight;
 
itemHeight := len({table.field1})/x
if len({table.field2})/x > itemHeight then
 itemHeight := len({table.field2})/x
...
 
//off the top of my head I don''t know if round, fix, cint will give the next number up.  if item.Height=1.3, you want to make it 2, so maybe adding 1 and then using FIX or cint will give you an integral number
 
pageLength := sectionHeight * itemHeight;
""
 
that should give you a good start.  X is some length that would cause the field to grow to multiple lines.  The new page before will then look at the shared variable and compare it to the length of the page desired...something like:
shared numbervar pageLength;
pageLength + thisSectionHeight > x
 
or pageLenght + thisSectionHeight + NextSectionHeight > x
 
HTH
 
IP IP Logged
jackyhui
Newbie
Newbie


Joined: 29 Jun 2009
Online Status: Offline
Posts: 3
Quote jackyhui Replybullet Posted: 30 Jun 2009 at 10:34am
thanks for your reply. Let me add even some more problems.
The field contains english ASCII char and multi-byte Chinese char which len does not distinguish between these 2. The ASCII chars take up 1 unit (in fact, this is not true for Times New Roman) and Chinese chars take up 2.
 
Thanks again for your input. Are there any new feature in CR 10 or later which solve this problem in a easier way?
 
Aiya.. really difficult for a simple problem.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Jun 2009 at 11:29am
I was actually formulating the solution for XI.  I know you said 9, but for this issue I don't believe that enough has changed.  There is a option for position and Height, but I don't think that you can access them in the report.  I could be wrong as I have written a report that will allow the columns/fields to be moved from side to side, and you could probably move the field up and down, but I don't think that it will give the size of the object... The section does not have such a feature.
 
Several posts have been made along this line, and unfortunately, no one has come up with a better solution than counting lines, which is all that basically is.
 
It might look silly but it might be worth a try, and you're right, I'd forgotten that most fonts really aren't 1, but it should give an estimate/something that is acceptable.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum