Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q208696
Moderate: Requires basic macro, coding, and interoperability skills.

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

↑ Back to the top


Summary

This article shows you how to 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. NOTE: This article explains a technique demonstrated in the sample file, RptSmp00.mdb. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:
231851� ACC2000: Microsoft Access 2000 Sample Reports Available in Download Center

↑ Back to the top


More information

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

To add a blank line after every five lines in a report, follow these steps:
  1. Open the sample database Northwind.mdb.
  2. In the Database Window, click Reports under Objects, and then click New.
  3. In the New Report dialog box, click Report Wizard, select the Employees Table, and then click OK.
  4. In the Available Fields box, select EmployeeID, and then click the > button. Repeat this step for the LastName, FirstName, and BirthDate fields, and then click Next.
  5. Select BirthDate as the primary group level, click the > button, and then click Next.
  6. Select LastName as the field to establish sort order in Field 1, and then click Next.
  7. On the How would you like to lay out your report? screen, click Next.
  8. On the What style would you like? screen, click Next.
  9. On the What title would you like for your report? screen, type Employee Birthdays, and then click Finish.
  10. View the new report in Design view.
  11. On the View menu, click Code.
  12. Type the following lines in the module's Declarations section:
    Option Compare Database
    Option Explicit
    ' 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.
    Dim cLines As Integer
    Const cMaxLine=5
    					
  13. In the Object box of the code module, select Report. In the Procedure box of the code module, select Open. Type the following procedure:
    Private Sub Report_Open (Cancel As Integer)
       'This code initializes the cLines variable to zero.
       cLines = 0
    End Sub
    					
  14. In the Object box, select Detail. The Procedure box will change to Format. Type the following procedure:
    Private Sub Detail_Format (Cancel As Integer, FormatCount As _
                  Integer)
       ' This code adds a blank line by setting the NextRecord and
       ' PrintSection properties.
       If cLines Mod (cMaxLine+1) = 0 Then
          Me.NextRecord = False
          Me.PrintSection = False
       End If
       cLines = cLines + 1
    End Sub
    					
  15. Close the module, and then preview the report. Note that there is a blank line in the report after every five lines of detail.

↑ Back to the top


References

For more information about the NextRecord property, click Microsoft Access Help on the Help menu, type NextRecord property in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about the PrintSection property, click Microsoft Access Help on the Help menu, type PrintSection property in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB208696, kbdta, kbhowto

↑ Back to the top

Article Info
Article ID : 208696
Revision : 1
Created on : 12/12/2002
Published on : 12/12/2002
Exists online : False
Views : 334