Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternating line back color

Status
Not open for further replies.

wizcow

Programmer
May 11, 2002
13
CA
I have an idea that would make my lists easier to read.

If line 1 had a white background
and line 2 had a yellow background
and line 3 had a white background again
line 4 yellow again, and so on.

I would like to do this in my forms and in reports.

Does anyone have coding ideas to accomplish this?

Thanks
Tom
 
The Form answer depends on which version of Access you are using....

In a report, place the following code in the OnFormat property of the Detail section and simply change to colors to the two you wish to have....

'**************Begin Code***********
Const cLightGrey = 12632256
Const cWhite = 16777215

If Me.Detail.BackColor = cWhite Then
Me.Detail.BackColor = cLightGrey
Else
Me.Detail.BackColor = cWhite
End If

"As far as the laws of mathematics refer to reality, they are not certain; as far as they are certain, they do not refer to reality."--Albert Einstein [spin]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
 
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    'Michael Red.   2/13/2002.      To 'Toggle the backolor, which
    'Provides alternate line shading
    Const XorToggle = 4144959

    Me.Detail.BackColor = Me.Detail.BackColor Xor XorToggle

End Sub

mstrmage1768 is correct, this workd for REPORTS - Forms depend on the ver. Also not that BOTH routines alternate white / lt grey, so you need to look up the color number for the "shade" of yellow you want. for his, just do the subst, for mine you need to do the math.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top