ACC2000: How to Print a Label After a Set Number of Lines of a Report

ID: Q207681


The information in this article applies to:
  • Microsoft Access 2000

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

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


SUMMARY

This article describes how to display a label after a set number of printed lines of data on a report. For example, you can use this method to display a label after every third line of data in your report.


MORE INFORMATION

In order to display a label after every three lines in a report, follow these steps:

  1. Start Microsoft Access, and open the sample database Northwind.mdb or the sample project NorthwindCS.adp.


  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 from the list box indicating where the object's data comes from, and then click OK.


  4. Select one-by-one the EmployeeID, LastName, FirstName, and BirthDate fields from the Available Fields list by highlighting each field, and then clicking the > button. The selected fields will appear in the Selected Fields list.


  5. Click Finish.


  6. On the View menu, click Design View.


  7. Click the Detail bar to select the detail section of the report. On the View menu, click Properties.


  8. Click the Format tab, and then change the Height property to 0.75".


  9. Add a text box to the detail section of the report below the existing fields, and set the following properties:


  10. Name: txtCounter
    Control Source: =1
    Running Sum: Over All
    Visible: No
  11. Add another text box to the detail section, and set the following properties:


  12. Name: txtTextLabel
    Control Source: ="Any text you want on your label"
    Top: .25"
    Height: .45"
    Visible: No
    Can Shrink: Yes
    Can Grow: Yes
  13. Select only the label attached to the txtTextLabel text box, and then press DELETE. This prevents the text box label from appearing with the text box.


  14. Click the Detail bar to select the detail section of the report.


  15. In the Properties box, click the Event tab.


  16. Right-click the On Format box, and then on the shortcut menu, click Build. In the Choose Builder dialog box, click Code Builder, and then click OK.


  17. Type the following code:


  18. 
    Private Sub Detail_Format (Cancel As Integer, _
          FormatCount As Integer)
       If ((Me![txtCounter]) Mod 3 = 0) Then
          Me![txtTextLabel].Visible = True
       Else
          Me![txtTextLabel].Visible = False
       End If
    End Sub 
  19. On the File menu, click Close and Return to the Microsoft Access.


  20. On the File menu, click Print Preview. Note that the label appears after every third record.



REFERENCES

For additional information about formatting reports based on a set number of lines per group, click the article numbers below to view the articles in the Microsoft Knowledge Base:

Q208696 ACC2000: How to Print a Blank Line Every Nth Line in a Report
For more information about using the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
Q212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

Additional query words: inf printing have appear insert inserting

Keywords : kbdta FmrCdbeh FmrHowto RptLayou
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 26, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.