Microsoft KB Archive/210044

= ACC2000: How to Print Labels on the Left Margin of a Report =

Article ID: 210044

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210044



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
When you print a column report, it is sometimes necessary to display a label for each row of detail being printed within the column. However, when the report is a multicolumn report, each new column in the multicolumn report redisplays these labels.

Microsoft Access does not have a report option that enables the printing of labels only along the left margin of a report. A report that requires this type of output also requires modifications by the user of the report.

This article shows you how to modify a report so that when you print a multicolumn report, the labels for each row of information in the columns are printed only along the left margin of the report.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. 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 print labels on the left margin of a multicolumn report, follow these steps:  Open the sample database Northwind.mdb. Create a new report based on the Customers table in Design view. Add 11 text boxes without labels to the left margin of the Detail section, beginning with the first text box in the upper-left corner. As you add each new text box, place it directly under the last text box.

NOTE: To avoid the automatic creation of labels with each new text box, click the Text Box button on the toolbox. On the View menu, click Properties, and then set the AutoLabel property to No. Set the Width property for each text box to 2" . Set the Name property of the first text box to txt1, the Name property of the second text box to txt2 , and so on. Click the ControlSource property for the txt1 text box, and then set the property to the first field name in the list. Click the ControlSource property for the txt2 text box, and then set the property to the second field name in the list. Continue this process for all 11 text boxes.</li> To the right of each text box, create a label. As each new label is created, in the label, type the name of the field that appears in the text box that is to the left of the new label.</li> Set the Name property of the first label to lbl1 , the Name property of the second label to lbl2 , and so on.</li> Set the Width property of each label to 2" .</li> Drag the lbl1 label directly over the txt1 text box, and drag the lbl2 label directly over the txt2 text box, and so on.</li> Set the Width property of the report to 2", and then set the Height property of the Detail section to 3" .</li> Click Page Setup on the File menu, and then set all margins to 0.5" .</li> Click the Page tab, and then under Orientation, click Landscape.</li> On the Columns tab, type 4 in the Number of Columns box; under Column Layout, click Down, then Across, and then click OK.</li>  Set the OnFormat property of the Detail section to the following event procedure: Dim i As Integer If Me.Left <Me.Width Then    Me.NextRecord = False    For i = 1 To 11        Me("txt" & i).Visible = False        Me("lbl" & i).Visible = True    Next i Else    For i = 1 To 11        Me("txt" & i).Visible = True        Me("lbl" & i).Visible = False    Next i End If                    </li> On the File menu, click Close and Return to Microsoft Access.</li> On the File menu, click Print Preview; notice that the labels are on the left side of the report.</li></ol>

NOTE: The Width and the Height property values that are used throughout this example vary from report to report.

Keywords: kbhowto kbinfo kbusage KB210044

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.