The information in this article applies to:
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.
MORE INFORMATION
The KeepTogether property is used to keep all of the controls for one
record together in a particular section of a report. This property
does not keep multiple records together, nor does it keep a group
header and its detail records together.
Method 1To keep a set number of records together on a single page with the group header, you need to know approximately how many records will be printed per group, or, more importantly, how many records you want to print with a particular group header. You can preview your report to find the group that prints the most records to determine how many records to keep with the group header.For example, say you have determined that the largest group prints 24 records. The detail section of your report is 1/4 inch in height; thus, 24 detail records take up 6 inches on a page. You must also consider the top and bottom margins, which default to 1 inch each, and the height of your group header section. Using the Report.Top property, you can determine where on the page the next section will be printed. If enough space remains to print your group header, all of its detail records, and the page footer (if any), plus the bottom margin, your group header will be printed on the same page as its detail records. If there is not enough blank space, delay printing the report (use a combination of the MoveLayout, NextRecord, and PrintSection properties to leave the rest of the page blank) and continue the group header information on the next page. Below are sample measurements on which this article's calculations are based:
Add the following values together:
To determine the blank space left on the page for detail records, subtract
the total above from your Page Length property value (11 inches - 5 inches
= 6 inches).
Divide the maximum space for detail records by the Detail.Height property value (6 inches / 0.25 inch). A total of 24 detail records will fit on a page. Force a new page if fewer than 8 records will print with the header (for example, if the formula returns either less than the sum of 8 * 0.25 inches or less than 2 inches of blank space). To determine where the top of the 2-inch limit is, or the point beyond which you should not print the group header, add the following values together:
Final calculation for the function: = 6 inches or (6 * 1440 twips)
To implement this calculation in a module, use the following steps:
Method 2Another way to avoid an abandoned group header at the bottom of a page, or not to print the group header beyond a certain position on the page, is to replace (6*1440) in the function above with the twip location beyond which you do not want to print.The report tests the Top property; if the condition is True, the report does not print the section. Instead, it moves down the report layout and attempts to print the section until the condition is False, which occurs at the top of the next page. For a multi-column report, the function must be modified as follows:
NOTE: This function will not work properly if Item Layout is set to
Horizontal (in Print Setup) for the columns.
Additional query words:
Keywords : kbusage |
Last Reviewed: October 13, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |