John Skolits submitted this report-enhancing code, which colors every other line in the Detail section of a report. Simply open the report’s module, drop in the code and review the report in Print Preview. You’ll probably need to select the Transparent setting for each control’s Back Style property.
Option
Compare Database
Option Explicit
'****Creating Graybar reports****
'Code
written by John Skolits,
'Copyright 2001, Corporate Data Design Inc.
'Feel free to use it in any application,
'The copyright notice should be left as is.
'Have a question? Just email me.
'JSkolits@CorporateDataDesign.com
'*To use
this code
'*Just copy all this code into a report's module
'***This code will make the 'detail' section of the report _
flip, between a grey and 'white background every other _
record. In order to use this, all the controls in the _
detail section, must 'have the 'Back Style' property _
set to 'Transparent'. You may also wish to make the _
border style 'Transparent' as well.
'Note: This will work only for the 'detail' section.
Dim
lcl_bolGrayBar As Boolean
Dim lcl_intColorFlipFlop2 As Boolean
Dim lcl_intColorFlipFlop1 As Boolean
Private Sub Report_Open(Cancel As Integer)
'**This
tells the code that you wish to have Graybar _
on your report
lcl_bolGrayBar = True
'****OPTIONAL:
You could also create a table ("tblReportSelection") _
with a yes/no field ("[bolGreyBar]"), and use the following
line _
of code to decide whether or not to run the Greybars. _
Then the user can then decide when they want greybars.
'lcl_bolGrayBar = DLookup("[bolGreyBar]",
"[tblReportSelection]")
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If
lcl_bolGrayBar Then
If lcl_intColorFlipFlop2 = True Then
Me.Detail.BackColor = 12632256
'Light Gray
lcl_intColorFlipFlop2 = False
Else
Me.Detail.BackColor = vbWhite 'White
lcl_intColorFlipFlop2 = True
End If
End If
End Sub
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If
lcl_bolGrayBar Then
If lcl_intColorFlipFlop1 = True Then
Me.Detail.BackColor = 12632256
'Light Gray
lcl_intColorFlipFlop1 = False
Else
Me.Detail.BackColor = vbWhite 'White
lcl_intColorFlipFlop1 = True
End If
End If
End Sub
John
Skolits ©2001
May be
distributed as long as the copyright remains.
(bio to be added later - please check back.)