|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports: Page breaks, conditionalYou can make page breaks conditional. This is ideal for fixed layout reports like invoices and cheques. Use a variable to behave as a line counter and keep track of the lines as you print them.In the Page Header: WhilePrintingRecords; Numbervar linecounter:=0; In Each Printing Section (including details): WhilePrintingRecords; Numbervar linecounter:=linecounter + 1; Conditional "New Page Before" in the details section: WhilePrintingRecords; Numbervar linecounter; linecounter>60 //or replace the 60 with the number of lines you can print This technique will also work across multiple subreports. If you are using subreports, you will need to declare the variables as shared. The prize goes to Trevor Nunes of UpTime for working this one through with us. You can also do page breaks on groups. One of the reasons for creating a group in Crystal Reports is to have each group start on a new page. There are several situations which can be easy to control if you understand how the section expert works with "New Page Before" or New Page After." You can use either of these properties to set page breaks, but we find it is simpler to focus on using just one of these. If you’ve just got one level of group in your report, set your "New Page Before" on Group Header 1. To get rid of the blank first page this creates, you also need to suppress the "Report Header" section. If you have multiple groups in your report, and you want a page break for a lower level group (e.g. Group 3), suppress the higher level group headers, and set "New Page Before" on your selected group (in this case Group 3). Depending on how often you want to see the higher level group names, you can put the Group 1 Name and Group 2 Name objects in either the Page Header or the Group 3 Header sections.
On the other hand, you can also group on pages. Using groups in a report is one of the major strengths of Crystal Reports. Creating the right groups and using them effectively is one of the skills you quickly develop. Use the group header, and display the group name and other fields to identify the group. It can also be useful to move the column headings from the Page Header to the Group Header section. But what if you have a large group that flows over to a subsequent page? How do you control the report so the headings re-appear on each page as the group continues? When you create the group, select the option "Repeat Group Header on Each Page." This will cause the group header to appear on each new page. If you have forgotten to set this, you can change an existing group, and set it later when you need to. Here's another tip on this subject: Display “Continued” when a group continues onto a new page. It can also be useful to display the word “Continued” when then the group header is not the start of the group. Place this formula in the group header section: If InRepeatedGroupHeader then “Continued”
On a related topic, you can also group by field. You can group by the same field more than once. This could be useful if you have used Specified Order for the higher level group, or the report is TopN and you would like the "Others" group to show totals by the original field at the next level down. However if you use that summary in a formula, interesting things happen. The summary is referred to in the formula as
There is nothing in that formula to distinguish which of the two levels summaries you want. So the formula will always display the higher level total. This means you can’t use the lower level summary in that form in the report. If you want the lower level summary in a formula you will need to create a formula to calculate the original group field. Then create the lower level group by the formula rather than the field. You can use this summary in a formula. We have a sample report to demonstrate this available from our web site to illustrate this. Grouping by a field more than once is available in Crystal Reports versions 9, 10 and XI. Crystal Reports 8.5 and earlier will not allow you to create a group if the field is already used for grouping. However, our formula field solution lets you group by a field more than once for any version of Crystal Reports. And the summaries don’t get confused when you use them in formulas.
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |