Help and Support
 

powered byLive Search

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

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:120842
Last Review:July 5, 2002
Revision:1.0
This article was previously published under Q120842
Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

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.

Back to the top

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, 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.

Back to the top

REFERENCES

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

Back to the top


APPLIES TO
Microsoft Access 2.0 Standard Edition

Back to the top

Keywords: 
kbhowto kbusage KB120842

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.