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.
- 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.
- Set the Name property of the first label to lbl1, the Name property of the second label to lbl2, and so on.
- Set the Width property of each label to 2".
- Drag the lbl1 label directly over the txt1 text box, and drag the lbl2 label directly over the txt2 text box, and so on.
- Set the Width property of the report to 2", and then set the Height property of the Detail section to 3".
- Click Page Setup on the File menu, and then set all margins to 0.5".
- Click the Page tab, and then under Orientation, click Landscape.
- On the Columns tab, type 4 in the Number of Columns box; under Column Layout, click Down, then Across, and then click OK.
- 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
- On the File menu, click Close and Return to Microsoft Access.
- On the File menu, click Print Preview; notice that the labels are on the left side of the report.
NOTE: The
Width and the
Height property values that are used throughout this example vary from report to report.