KeepTogether Property - Sections

Microsoft Access Visual Basic

Show All Show All

KeepTogether Property - Sections

You can use the KeepTogether property for a section to print a form or report section all on one page. For example, you might have a group of related information that you don't want printed across two pages.

Note  The KeepTogether property applies only to form and report sections (except page headers and page footers).

Setting

The KeepTogether property for a section uses the following settings.

Setting Visual Basic Description
Yes True Microsoft Access starts printing the section at the top of the next page if it can't print the entire section on the current page.
No False (Default) Microsoft Access prints as much of the section as possible on the current page and prints the rest on the next page.

You can set this property by using the section's property sheet, a macro, or Visual Basic.

The KeepTogether property for a section can only be set in form Design view or report Design view.

Remarks

Usually, when a page break occurs while a section is being printed, Microsoft Access continues printing the section on the next page. By using the section's KeepTogether property, you can print the section all on one page. If a section is longer than one page, Microsoft Access starts printing it on the next page and continues on the following page.

If the KeepTogether property for a group is set to Whole Group or With First Detail and the KeepTogether property for a section is set to No, the KeepTogether property setting for the section is ignored.

Example

The following example returns the KeepTogether property setting for a report's detail section and assigns the value to the variable intGetVal .

Dim intGetVal As Integer
intGetVal = Me.Section(acDetail).KeepTogether