Alternating colours in Access 2007 report

J

John

Hello.

I'm creating a report in Access 2007, and I'd like to have alternating
colours. The challenge is that the actual option for alternating
colours seems to only apply to the detail records, but I want each
group to have alternating colours, and the groups can have a varying
number of detail records. I have managed this before in Access 2003,
but for some reason it's not working in 2007. My logic is pretty
simple:

1) I have a counter variable that counts the number of groups - it
gets initialized to 0 when the report opens.
2) When a Group Header is formatted, it checks to see if the counter
is divisible (evenly) by 2. If it is, it sets the group header back
colour to light blue. If not, it sets it to white.
3) On detail format, it sets the detail back colour to whatever the
back colour of the group header is.
4) On group footer format, it sets the group footer back colour to
whatever the back colour of the group header is, and then increments
the counter by 1.

Now here's the strange thing: according to what I have displaying in
the debug window, it's actually setting the colours properly. The
problem is that it's not displaying the report showing the colours
that it set. This is what displays in the debug window:

Group: 1 Event: HEADER FORMAT Header Color: 16180438 Detail
Color: 16777215 Footer Color: 16777215
Group: 1 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 1 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 1 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 1 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 1 Event: FOOTER FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16180438 <--
Group: 2 Event: HEADER FORMAT Header Color: 16777215 Detail
Color: 16180438 Footer Color: 16180438
Group: 2 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 2 Event: FOOTER FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16777215 <--
Group: 3 Event: HEADER FORMAT Header Color: 16180438 Detail
Color: 16777215 Footer Color: 16777215
Group: 3 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 3 Event: FOOTER FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16180438 <--
Group: 4 Event: HEADER FORMAT Header Color: 16777215 Detail
Color: 16180438 Footer Color: 16180438
Group: 4 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 4 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 4 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 4 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 4 Event: FOOTER FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16777215 <--
Group: 5 Event: HEADER FORMAT Header Color: 16180438 Detail
Color: 16777215 Footer Color: 16777215
Group: 5 Event: DETAIL FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16777215
Group: 5 Event: FOOTER FORMAT Header Color: 16180438 Detail
Color: 16180438 Footer Color: 16180438 <--
Group: 6 Event: HEADER FORMAT Header Color: 16777215 Detail
Color: 16180438 Footer Color: 16180438
Group: 6 Event: DETAIL FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16180438
Group: 6 Event: FOOTER FORMAT Header Color: 16777215 Detail
Color: 16777215 Footer Color: 16777215 <--

Note that after every Footer Format event, all of the colours match,
as they should. (On a side note, there are actually only 3 groups
displaying on the report - for some reason, Access is formatting the
report twice.) I can't really post a picture of what's actually being
displayed, so hopefully this makes sense:

Header 1: (not displayed because the height is 0)
Detail 1a: white
Detail 1b: white
Detail 1c: white
Detail 1d: white
Footer 1: white
Header 2: (not displayed)
Detail 2a: light blue
Footer 2: white
Header 3: (not displayed)
Detail 3a: white
Footer 3: white

This is turning into a lengthy message. Hopefully it made some sense.
I'm thinking there's probably something really simple that I'm
missing, but I've been staring at it and trying things for several
hours with no luck.

Thanks for any help.

John
 
M

Marshall Barton

John said:
I'm creating a report in Access 2007, and I'd like to have alternating
colours. The challenge is that the actual option for alternating
colours seems to only apply to the detail records, but I want each
group to have alternating colours, and the groups can have a varying
number of detail records. I have managed this before in Access 2003,
but for some reason it's not working in 2007. My logic is pretty
simple:

1) I have a counter variable that counts the number of groups - it
gets initialized to 0 when the report opens. [snip}
. . . and then increments the counter by 1. [snip]
. . . for some reason, Access is formatting the report twice.)
[snip]


Because a report may be formatted as many times and in
whatever order as needed to deal with your property settings
(e.g. KeepTogether, Can Grow/Shrink, Pages, etc) and
previewing order, using code to count/number the
records/sections might work in a few special cases, but in
general is extremely unreliable.

Instead you should use a running sum text box in the detail
section to number the details and a separate running sum
text box in a group header to number the instances of a
group.
 
R

ryguy7272

Although it's for an older version of Access, maybe this will give you some
ideas:
http://www.datapigtechnologies.com/flashfiles/linenuminreport.html

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Marshall Barton said:
John said:
I'm creating a report in Access 2007, and I'd like to have alternating
colours. The challenge is that the actual option for alternating
colours seems to only apply to the detail records, but I want each
group to have alternating colours, and the groups can have a varying
number of detail records. I have managed this before in Access 2003,
but for some reason it's not working in 2007. My logic is pretty
simple:

1) I have a counter variable that counts the number of groups - it
gets initialized to 0 when the report opens. [snip}
. . . and then increments the counter by 1. [snip]
. . . for some reason, Access is formatting the report twice.)
[snip]


Because a report may be formatted as many times and in
whatever order as needed to deal with your property settings
(e.g. KeepTogether, Can Grow/Shrink, Pages, etc) and
previewing order, using code to count/number the
records/sections might work in a few special cases, but in
general is extremely unreliable.

Instead you should use a running sum text box in the detail
section to number the details and a separate running sum
text box in a group header to number the instances of a
group.
 
J

John

John said:
I'm creating a report in Access 2007, and I'd like to have alternating
colours. The challenge is that the actual option for alternating
colours seems to only apply to the detail records, but I want each
group to have alternating colours, and the groups can have a varying
number of detail records. I have managed this before in Access 2003,
but for some reason it's not working in 2007. My logic is pretty
simple:
1) I have a counter variable that counts the number of groups - it
gets initialized to 0 when the report opens. [snip}
. . .  and then increments the counter by 1. [snip]
. . .  for some reason, Access is formatting the report twice.)

[snip]

Because a report may be formatted as many times and in
whatever order as needed to deal with your property settings
(e.g. KeepTogether, Can Grow/Shrink, Pages, etc) and
previewing order, using code to count/number the
records/sections might work in a few special cases, but in
general is extremely unreliable.

Instead you should use a running sum text box in the detail
section to number the details and a separate running sum
text box in a group header to number the instances of a
group.

I just tried using the running sum box instead, but I was still
getting the same problem. I did manage to figure it out though -
basically, the problem was that I'm apparently a bit of a moron :)
There's a BackColor property and an Alternate Back Color property - I
had the alternate one set to #FFFFFF instead of "no color". As soon as
I changed that, it worked perfectly (I left the running sum box in). I
knew it had to be something simple that I was missing. Thanks for the
help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top