Microsoft KB Archive/119075

= ACC: How to Control the Number of Records Printed Per Page =

Article ID: 119075

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q119075



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



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



MORE INFORMATION
You can control the number of records printed per page on a report by setting the page break's Visible property. The following example demonstrates how to print three records per page on a report:

 Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x or 2.0).  Create a new macro with the following action, and then save the macro as Detail Page Break:

     Macro Action ---     SetValue Item: [PageBreak].Visible Expression: IIf([TheCounter] Mod 3 = 0, "True", "False")  Follow these steps to create a report called Test1 based on the Suppliers table:

 In the Database window, click the Report tab, and then click New. Select the Suppliers table and click OK.

NOTE: In versions 1.x and 2.0, select the Suppliers table, and then click Blank Report.  Add the following text boxes to the detail section of the report:

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

Text Box: Name: Address ControlSource: Address Text Box: Name: City ControlSource: City Text Box: Name: Region ControlSource: Region

NOTE: In Microsoft Access version 1.x, the Name property is called the ControlName property. </li></ol> </li>  Add a text box with the following properties to the detail section. Place the text box directly on top of the Address control. This control will act as a counter for the number of records in the report:

<pre class="fixed_text">     Text Box Name: TheCounter ControlSource: =1 Visible: No        RunningSum: Over All </li> Set the detail section's OnFormat property to the Detail Page Break macro.</li> Add a page break control to the bottom left corner of the detail section beneath the Address control.</li> Set the page break control's Name property to PageBreak.</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.

You can modify this example to print any number of records per page by changing the expression in the Detail Page Break macro 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:

<pre class="fixed_text">  IIf([TheCounter] mod 11 = 0, "True", "False")

<div class="references_section">