Simone,
Doubtless someone can offer a better method (using an array probably), but
here's my hack, which uses a work table to keep track of the shading to
apply to the alternating groups.
1) Create a work table to use with the report:
CREATE TABLE WORK_SHADING
( GroupName text(100) NOT NULL,
lngColor long NOT NULL,
OrderNum byte NOT NULL
);
ALTER TABLE WORK_SHADING
ADD CONSTRAINT PK_WORK_SHADING PRIMARY KEY
( GroupName );
2) Populate the work table with the shading values to apply to the groups.
In the report open event, add this code (note you'll need to change the
asterisked query so the groups and ordering matches the data and ordering on
your report):
Dim db As Database, rs As Recordset
Dim i As Integer, lngColor As Long
i = 1
lngColor = 16777215 'WHITE
Set db = CurrentDb()
db.Execute ("DELETE FROM WORK_SHADING;")
*** Set rs = db.OpenRecordset("SELECT DISTINCT GroupName FROM TABLE ORDER BY
'however it is ordered on your report';")
Do Until rs.EOF
If lngColor = 12632256 Then
lngColor = 16777215 'WHITE
Else
lngColor = 12632256 'GRAY
End If
db.Execute ("INSERT INTO WORK_SHADING (GroupName, lngColor, OrderNum)
VALUES('" & rs("GroupName") & "', " & lngColor & ", " & i & ");")
i = i + 1
rs.MoveNext
Loop
rs.Close
3) Apply the shading colors to the report. In the Detail_Format event of
the Report, add:
Me.Detail.BackColor = DLookup("lngColor", "WORK_SHADING", "GroupName = '" &
Me.GroupName & "'")
"Simone" <oi****@hotmail.com> wrote in message
news:fc**************************@posting.google.c om...
I just wanted to follow up on this post that I would like to make it
gray or white depending on the group. Please disreguard the sub report
I eliminated it and now I am using group header.
Example
Group A
1
2
3
all gray
Group A
1
2
3
all white.
I can'get that right, it makes every other row white or gray and I
want all rows for that group white or gray.
Thanks
Simone
oi****@hotmail.com (Simone) wrote in message
news:<fc**************************@posting.google. com>...
Hello.
I am using the code below:
-------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 15724527
Else
Me.Section(0).BackColor = vbWhite
End If
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Detail.BackColor = 16777215
End Sub
-------------------------------------------
The problem I am having is that on each row(detail section) there is a
sub report and I don't know how to access the sub report(detail) back
color to change with the main report.
Any ideas?
Thanks
Simone Dupre