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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternating Background Colours 2

Status
Not open for further replies.

Ctrler

MIS
Oct 31, 2001
18
0
0
FI
How can I create a report with alternating background colours for each record line (price list-style)? I would assume something including an OnFormat event based on odd and even row numbers would do the trick, but perhaps someone has an easier solution at hand.

Thanks, Gion
 
I think you're right, the simplest solution is to introduce some code in the Format (?or Print) event procedure of the Detail Level.
Create a global variable at the module level in the module attached to the Report:

>>Dim FlipColor as Boolean

Initialize it in the Form_Load event procedure

>>FlipColor=True

Switch the BackColor of the detail section in the Format event procedure:

>>If FlipColor=True Then
>>Me.Section(0).BackColor=XXXXXX
>>Else
>>Me.Section(0).BackColor=YYYYYY
>>End If
>>FlipColor=Not FlipColor
 
Another way to do it is just to put this in the OnFormat event of the section you want to flip:

[tt]
Const cLightGrey = 12632256
Const cWhite = 16777215

If Me.Detail.BackColor = cWhite Then
Me.Detail.BackColor = cLightGrey
Else
Me.Detail.BackColor = cWhite
End If
[/tt]

That will flip between White and LightGrey.

HTH Joe Miller
joe.miller@flotech.net
 
Hey Joe,
that's exactly the kind of easy solution I was looking for. Works great - thanks a thousand!

Gion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top