Shading 3 lines and 3 without in report/detail

R

Robert

Hi

Pretty new to Access.
Have got a problem. Would like to get 1 of my reports
with backcolor in group of 3 lines/details. 3
lines/details with backcolor and 3 without.

Is there any easy way to progam this?

Robert
 
A

Allen Browne

You can do this very efficiently with Conditional Formatting. No code
needed.

1. Open your report in design view.

2. Select all the controls in the detail section, and set their Back Style
property to Transparent.

3. Add a text box to the detail section, and give it these properties:
Control Source =1
Running Sum Over Group
Format: General Number
Visible: No
Name: txtKt

4. Add another text box to the detail section.
Drag it so it covers the whole section.
From the Format menu, choose Send to Back.
From the Format menu, choose Conditional Formatting

5. Set Condition 1 of the Condtional Formatting to:
Expression Is ((([txtKt]-1)\3) Mod 2)=1
and click they gray you want in the Fill icon (bucket).

How it works:
- txtKt acts as a counter, incrementing by 1 each row;
- subtracting 1 results in counting 0, 1, 2, 3, 4, 5, 6, 7, ...
- integer division by 3 results in 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, ...
- Mod 2 yields 0 for even numbers, and 1 for odd numbers.
- The gray color is applied to even numbers.
 
M

Marshall Barton

Robert said:
Pretty new to Access.
Have got a problem. Would like to get 1 of my reports
with backcolor in group of 3 lines/details. 3
lines/details with backcolor and 3 without.

Is there any easy way to progam this?


Set this up similar to the shade every other line report
described in KB 114086
http://support.microsoft.com/default.aspx?scid=kb;en-us;114086
except that I think it's better to set the detail section's
BackColor instead of doing it for each control. Make sure
that you set every label and text box's BackStyle property
to Transparent.

The detail section's Format or Print event would then look
like:

If (((Me![LineNum] - 1) \ 3) Mod 2) = 0 Then
Me.Section(0).BackColor = vbYellow
Else
Me.Section(0).BackColor = vbWhite
End If

You'll have to tell me if this is easy or not ;-)
 

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