Microsoft KB Archive/209006

= ACC2000: How to Control the Number of Records Printed per Page =

Article ID: 209006

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209006



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article describes a method that you can use to control the number of records printed per page in a report.



MORE INFORMATION
You can control the number of records printed per page in a report by setting the Visible property for page breaks. The following example demonstrates how to print three records per page in a report:  Start Microsoft Access and open the sample database Northwind.mdb.  Follow these steps to create a report called Report1 based on the Suppliers table:  In the Database window, click Reports, and then click New. Select the Suppliers table, and then click OK. Add the following text boxes to the Detail section of the report, and place them on one line:

<pre class="fixed_text">  Report: Report1 --  Caption: TestReport ControlSource: Suppliers

Text Box: Name: Address ControlSource: Address Text Box: Name: City ControlSource: City Text Box: Name: Region ControlSource: Region </li>  Add a text box with the following properties to the Detail section. Place the text box directly above the Address control. This control acts as a counter for the number of records in the report: <pre class="fixed_text">  Text Box: ---     Name: Counter ControlSource: =1 Visible: No     RunningSum: Over All </li> Open the toolbox if it is not already open, click Page Break, and then add a page break control to the lower-left corner of the detail section. Place it directly below the Address control, and set the Name property to PageBreak.</li>  In the Detail section, set the OnFormat property to the following Event Procedure: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me![Counter] Mod 3 = 0 Then Me![PageBreak].Visible = True _ Else Me![PageBreak].Visible = False

End Sub </li> Minimize the amount of white space by moving the Page Footer bar to directly below the PageBreak control.</li>  Preview the report.

The first page of the report should contain the following three records: <pre class="fixed_text">Address          City            Region

49 Gilbert St.   London P.O. Box 78934   New Orleans     LA 707 Oxford Rd.    Ann Arbor       MI                    </li></ol>

If the last record is missing or is only partially displayed, the PageBreak control is not down far enough in the report's Detail section.

NOTE: You can modify this example to print any number of records per page by changing the code in the OnFormat property of the Detail section from "mod 3" to "mod x" where x is the number of records you want to print per page. For example, if you want to print 11 records per page, change the expression to read:

If Me![Counter] Mod 11 = 0 Then Me![PageBreak].Visible = True _ Else Me![PageBreak].Visible = False

<div class="references_section">