on format event procedure to back color a line of text

J

JohnLute

I use the following:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 13948116 'gray
Else
Me.Section(0).BackColor = vbWhite
End If

End Sub

How can this be modified to back color every line?

Thanks!
 
M

Marshall Barton

JohnLute said:
I use the following:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 13948116 'gray
Else
Me.Section(0).BackColor = vbWhite
End If

End Sub


You want the entire report to have a gray background?? If
so set the Detail sections BackColor property to what ever
color you want. No code needed if they're all the same.
 
J

JohnLute

Thanks, Marshall. Actually, I'd like each line to be shaded. I have
subreports that fall under under each line and it would be easier on the eyes
if each line were shaded. Right now the code shades every other line but
that's only helpful in a single subreport.

Hope that clarifies.
 
M

Marshall Barton

JohnLute said:
Thanks, Marshall. Actually, I'd like each line to be shaded. I have
subreports that fall under under each line and it would be easier on the eyes
if each line were shaded. Right now the code shades every other line but
that's only helpful in a single subreport.


It's not clear what you mean by "line".

If the "line" is in the same section as the subreport, just
in an area above the subreport, add a rectangle control to
the section, size/position it to the "line" area and set
it's back color to whatever you want. Then use the Format -
Send to Back menu item to put it behind all other controls
in the area. You will probably also want to set the other
controls' BackStyle property to Transparent.

If "line" has a different meaning, please explain in more
detail.
 
J

JohnLute

Sorry for the confusion.

I have a report with one vertical line of fields in the detail. Below this
line are subreports. The code I currently use shades alternating lines in the
report.

I'd like to shade every line.
 
M

Marshall Barton

JohnLute said:
Sorry for the confusion.

I have a report with one vertical line of fields in the detail. Below this
line are subreports. The code I currently use shades alternating lines in the
report.


That code you posted shades every other instance of the
entire detail section. As I said before, you can just set
the color you want to shade the section in the section's
BackColor property in the report's design view. There is no
code needed for that.

If that's not sufficient to answer your question. please
explain the layout of the report in terms of it's sections.
 
J

JohnLute

Thanks, Marshall.

Now I get it! I gave this a whirl and a problem occurs when there are
several records that don't have subreport records. This results in no breaks
in between the records and a giant block of shaded text which defeats the
purpose of shading.

Any way to code so that each vertical line is shaded?
 
M

Marshall Barton

JohnLute said:
Now I get it! I gave this a whirl and a problem occurs when there are
several records that don't have subreport records. This results in no breaks
in between the records and a giant block of shaded text which defeats the
purpose of shading.
Any way to code so that each vertical line is shaded?


John, I am really struggling to follow your terminology.
What is "each" line?? Is it the same field from several
records or is it several fields from a single record? And
how does a subreport separate anything? Maybe you have some
grouping in the report and the subreport is in a group
footer section??? It seems like you are talking in terms of
areas on a piece of paper, when you need to break it down to
the controls and sections in the report's design.

You said that everything is shaded and then ask if it can be
shaded. What does that mean?? I really think the problem
is fairly easy to deal with, but I really need more precise
and specific information before I can understand what we are
working on and what effect you want to achieve.
 
J

JohnLute

I have a report with one vertical line of fields in the detail. Below this
line are subreports. The code I currently use shades alternating lines in the
report.
--
www.Marzetti.com


Marshall Barton said:
John, I am really struggling to follow your terminology.
What is "each" line??

A single vertical plane of fields.

You know, I think I've created some confusion. My report is actually a
subreport. I was calling it a report in an effort to minimize confusion but
it may have done the opposite.

The subreport detail uses the code to shade alternating records.

I hope that clarifies. Sorry for the confusion.
 
M

Marshall Barton

JohnLute said:
I have a report with one vertical line of fields in the detail. Below this
line are subreports. The code I currently use shades alternating lines in the
report.


Just repeating yourself does not help me understand how your
report is organized. I need to know what sections you have
in the report and what controls (text boxes, etc) are in
each section.
 
J

JohnLute

srptFGProfilesAssociations has a detail with 6 fields lined up along the same
HOIZONTAL line. I see that I've been typing "vertical" - good grief! Sorry
for the brain cramp. One of the fields is a primary key.

Below that line are subreports that link to the primary key of
srptFGProfilesAssociations.

srptFGProfilesAssociations may display one or many records. I need to shade
each record.

Hope that helps. This has not been one of my best efforts!
 
M

Marshall Barton

JohnLute said:
srptFGProfilesAssociations has a detail with 6 fields lined up along the same
HOIZONTAL line. I see that I've been typing "vertical" - good grief! Sorry
for the brain cramp. One of the fields is a primary key.

Below that line are subreports that link to the primary key of
srptFGProfilesAssociations.

srptFGProfilesAssociations may display one or many records. I need to shade
each record.


Do you want to shade each detail in
srptFGProfilesAssociations the same color or different
colors? The code you posted before shaded the entire detail
with two alternating, different colors, but you don't like
something about that. I suggested a couple of ways to shade
all or part of the details with the same color. I still
think the answer you are looking for is the rectangle
approach I suggested before, but if that is not what you
want, please explain what about it does not meet your needs.
 

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