Discussion Locked

Access 97 - Every Other Line Shading

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am currently using Access 97.

I would like to know how to print my reports with multiple lines where I could have every other line shaded for easy reading across a line.

Thanks,

Gary

5 replies

by jgillespie

Q114086
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access.
The following example uses an event procedure to alternate the background color between white and yellow. On black and white printers, yellow typically appears as light gray.
Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0), and then open the Alphabetical List Of Products report in Design view.
Add a new text box control to the report's detail section and set the following properties:
Name: LineNum
ControlSource: =-1
RunningSum: Over All
Visible: No
Note the equal sign in the ControlSource property setting.
Add the following code to the Print event of the detail section. To do so, follow these steps:
With the properties box open, click the detail section header.
In the properties box, click the OnPrint property and click the Build button. Click Code Builder, and then c

by joe giaquinto

Hi Gary. Try this:

1. Save a table with two fields, FirstName and LastName.
2. Create a report in design view. Place two text boxes, txtFirstName and txtLastName in the detail section.
3. Set the form’s data source to the table you just created.
4. Set the control source of each text box to FirstName and LastName, respectively.
5. Enter the following code in the report module and save this report:

Option Compare Database
Option Explicit
Private fShaded As Boolean
Private Sub Report_Open(Cancel As Integer)
fShaded = True
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case fShaded
Case True
Me.Detail.BackColor = 12632256 'gray
fShaded = False
Case False
Me.Detail.BackColor = 16777215 'white
fShaded = True
Case Else
End Select
End Sub

Tips: Set the BackStyle of the text boxes to Transparent. Otherwise, each text box’s own BackColor will mask the sha

This discussion is closed to new replies.