ACC2: How to Print Blank Line Every Nth Line in a Report

Last reviewed: July 15, 1997
Article ID: Q120842
The information in this article applies to:
  • Microsoft Access version 2.0

SUMMARY

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

This article describes how you can add blank lines between the printed lines on a report. You can use this method to add a blank line after a set number of lines. For example, you could use this method to add a blank line after every five lines of data in your report.

MORE INFORMATION

The following example demonstrates how to add a blank line after every five lines in a report:

  1. Open the sample database NWIND.MDB and create a new report based on the Employees table. Choose the Report Wizards button, and then follow these steps:

        a. In the "Which Wizard do you want?" screen, select Tabular and
           then choose the OK button.
    

        b. In the Available Fields box, select Employee ID and then choose
           the ">" button. Repeat for Last Name, First Name, and Birth Date,
           and then choose the Next button.
    

        c. In the Available Fields box, select Birth Date and then choose
           the ">" button. Choose the Next button.
    

        d. In the "What style do you want for your report?" screen, choose
           the Next button.
    

        e. In the "What title do you want for your report?" screen, type
           "Employee Birthdays" (without quotation marks), and then choose
           the Finish button.
    

  2. View the new report in Design view.

  3. From the View menu, choose Code.

  4. Enter the following code in the module:

          Option Compare Database
          Dim cLines As Integer
          Const cMaxLine=5
    

    This code declares the cLines variable as an integer, and the cMaxLine constant as five. You can set the cMaxLine constant to insert a blank line after as many lines as you want. For example, to add a blank line after every eight lines in the report, set cMaxLine=8.

  5. In the Object box on the toolbar, select Report. In the Procedure box on the toolbar, select Open. Enter the following code in the module:

          Sub Report_Open (Cancel As Integer)
             cLines = 0
          End Sub
    
       This code initializes the cLines variable to zero.
    
    

  6. In the Object box, select Detail1. In the Procedure box, select Format. Enter the following code in the module:

          Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
             If cLines Mod (cMaxLine+1) = 0 Then
                Me.NextRecord = False
                Me.PrintSection = False
             End If
             cLines = cLines + 1
          End Sub
    
       This code adds a blank line by setting the NextRecord and PrintSection
       properties.
    
    

  7. Close the module, and then preview the report. Note that there is a blank line in the report after every five lines.

REFERENCES

Microsoft Access "User's Guide," version 2.0, pages 677-680


Keywords : kbusage RptLayou
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 15, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.