Microsoft KB Archive/207681

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

Article ID: 207681

Article Last Modified on 3/10/2003

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207681



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

This article applies to a Microsoft Access database (.mdb) and to 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:  Start Microsoft Access, and open the sample database Northwind.mdb or the sample project NorthwindCS.adp. In the Database window, click Reports under Objects, and then click New. 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. 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. Click Finish. On the View menu, click Design View.</li> Click the Detail bar to select the detail section of the report. On the View menu, click Properties.</li> Click the Format tab, and then change the Height property to 0.75".</li> Add a text box to the detail section of the report below the existing fields, and set the following properties:

Name: txtCounter

Control Source: =1

Running Sum: Over All

Visible: No

</li> Add another text box to the detail section, and set the following properties:

Name: txtTextLabel

Control Source: ="Any text you want on your label"

Top: .25"

Height: .45"

Visible: No

Can Shrink: Yes

Can Grow: Yes

</li> 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.</li> Click the Detail bar to select the detail section of the report.</li> In the Properties box, click the Event tab.</li> 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.</li>  Type the following code: 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 </li> On the File menu, click Close and Return to the Microsoft Access.</li> On the File menu, click Print Preview. Note that the label appears after every third record.</li></ol>

<div class="references_section">