ACC2000: How to Print a Label After a Set Number of Lines of a Report
ID: Q207681
|
The information in this article applies to:
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:
- 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.
- Click the Detail bar to select the detail section of the report. On the View menu, click Properties.
- Click the Format tab, and then change the Height property to 0.75".
- 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
- 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
- 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.
- Click the Detail bar to select the detail section of the report.
- In the Properties box, click the Event tab.
- 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.
- 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
- On the File menu, click Close and Return to the Microsoft Access.
- On the File menu, click Print Preview. Note that the label appears after every third record.
REFERENCESFor 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
|