Formatting alternate records in reports

Jimmy Turnip

Registered User.
Local time
Today, 23:27
Joined
Sep 26, 2000
Messages
18
I have a report that summarises data in a table-like format. This report usually has a large number of rows in it, and can be quite hard to read. In order to make it easier to read, I want to shade alternate records. Is there a way of doing this? For example, if I wanted the background of the first 4 records unshaded, the next 4 shaded light blue, then the next 4 unshaded, etc.?

Thanks

[This message has been edited by Jimmy Turnip (edited 10-13-2000).]
 
Add this to the report module:

Private Sub AlternateGray()
On Error Resume Next
Const glrcColorGray = &HC0C0C0
Const glrcColorWhite = &HFFFFFF
Me.Section(0).BackColor = IIf(fGray, glrcColorGray, glrcColorWhite)
fGray = Not fGray

End Sub

Add this to the Declaration of the Report Module

Dim fGray as Boolean


Add this to the Report_Open Event

fGray = False 'Makes sure you start with white.

Add this to the Detail_Format Event

AlternateGray

[This message has been edited by Travis (edited 10-13-2000).]
 
Thanks a lot, that's a great help. You can also format alternate blocks of records by adapting the AlternateGray procedure to this:

intCount = intCount + 1
Me.Section(0).BackColor = IIf(fGray, glrcColorYellow, glrcColorWhite)
If intCount = conBlockSize Then
intCount = 0
fGray = Not fGray
End If

Here intCount is an integer and conBlockSize is a constant, and both are declared in the declarations section. conBlockSize will determine how many records are in each block. In the Report_Open procedure you add

intCount = 0

It's quite an effective way of presenting a report if you've got rows and rows of data.
 
I hope that someone reads this even at the end of a discussion string. I've made a report that I think would be great if I could apply this alternate shading. There are a couple of reports and so I'd like to define the code as a public function:

Public Function AlternateGray()
On Error Resume Next
Const glrcColorGray = &HC0C0C0
Const glrcColorWhite = &HFFFFFF
Me.Section(0).BackColor = IIf(fGray, glrcColorGray, glrcColorWhite)
fGray = Not fGray
End Function

The problem is then defining the report and replacing the variable "Me" in "Me.Section(0)..."

I think maybe I can do something along the lines of

Public Function AlternateGray(rpt As ?????)
and then --
rpt.Section(0).BackColor = IIf(fGray,

I'm not sure exactly what to put in the???? part or what exactly I need to define when I call the function.

Any ideas??

Kenneth
 
You can use CodeContextObject in place of the Me keyword to reference the target in a function if that's any help.

Ian
 
Thanks, that does help. That's what I needed to know.

Kenneth
 
Great Idea!

Fornation,

I'm gonna try this out! :)

Just put CodeContextObject. in place of Me. , right? Does that work in place of Me. for all code that might be more useful as a public function?:confused:
 
I am Interest in the Final Product !

Cosmos75,

If you are were successful and willing to share, I'd sure like a look at your public function to Shade Alternate Lines of a Report with Different Shades.

:D
 
Thank you very much for this code, it worked great. However, I wanted to change the color and maybe I didn't grab the right code list (I think it might be from Excel?). For example, I wanted to replace the HCOCOCO with CCCCFF (Pale weak blue) and it give me an error. It doesn't seem to like the "&" in front, but it doesn't like it without it either. Is there another list of color codes I should go to? or is there something in the coding that only allows for gray????

Thanks.

Therese
 

Users who are viewing this thread

Back
Top Bottom