Alternate rows with bold font

  • Thread starter Thread starter *Glen*
  • Start date Start date
G

*Glen*

Can anyone tell me how to make the rows in my detail section of the report
alternate between bold font and normal font to make the report easier to
read? Thanks!

Glen
 
Can anyone tell me how to make the rows in my detail section of the report
alternate between bold font and normal font to make the report easier to
read? Thanks!

Glen

Code the Detail Section Format event:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c
End Sub

It might be easier to read if, instead of bolding every other line,
you alternated the back color of the detail section.

First make sure the BackStyle of each control is Transparent.

Code the Detail Format event:

If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 12632256 ' gray
Else
Me.Section(0).BackColor = vbWhite
End If

====
If you wish each page to start with a white row, code the Page Header
Format event:

Me.Detail.BackColor = 12632256 'Reset color to Grey so that the
first detail line will become white

Change the colors as needed.
 
I coded the detail section format event as per the instructions below for the
bold font, but there was no change when I viewed the report or printed it
out. Did I miss something or am I supposed to change any words in the coded
to match my control names?
 
Thanks Al. I apologize for the multi-posts and did not realize that the MVPs
look at the report questions and the general questions.

I visited your site and saw the code, but do not know how to tailor it to my
need. I want to have alternating bold/normal font in the detail section of
my report. I followed Fred's code from 12/28, but there was no difference
when I viewed or printed the report. Any assistance is appreciated. Thanks!

Glen
 
I copied and pasted Fred's code into the On Format event code in a report and
it worked as expected. I would probably add something that determines if the
control is a text or combo box so it doesn't attempt to change the fontbold
property of a line control.

I agree with Fred that changing the back color is more pleasing to the eye.
 
Hmm...it must be something I am either doing incorrectly or I did not provide
you with enough information. Here's what I did:

(1) Opened report in design view
(2) Right-clicked on detail section
(3) Clicked on Event Tab
(4) Went to On Format Section
(5) Pasted code in the VB window

Other clues I need to mention:

(1) The background is already colored. This is why I need to alternate
between bold and normal font.

Well Duane...if it can be done, I'm sure that you can help me figure it out!
Thanks!

Glen
 
Hmm...it must be either something I am doing incorrectly or perhaps I did not
provide you with enough information. Here's what I did:

(1) Viewed report in design view
(2) Right-clicked on detail section
(3) Event Tab
(4) On-Format Section
(5) Pasted code

Information that may be useful:

(1) I have a colored background (not conditional formatting, just filled
text boxes). This is why I need to alternate between bold and normal font.

Thanks!
 
Hmm...it must be either something I am doing incorrectly or perhaps I did not
provide you with enough information. Here's what I did:

(1) Viewed report in design view
(2) Right-clicked on detail section
(3) Event Tab
(4) On-Format Section
(5) Pasted code

Information that may be useful:

(1) I have a colored background (not conditional formatting, just filled
text boxes). This is why I need to alternate between bold and normal font.

Thanks!

It appears you have placed the code in the wrong place.
All is well until (3) Event Tab.
On the Event tab, on the On Format line, write:
[Event Procedure]
Then click on the little button with 3 dots that appears on that line.
When the Code window opens, the cursor will be flashing between 2
lines of existing code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

End Sub

Between those 2 lines write:

Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c

Exit the window and save the report.
When you run the report the lines should alternate Bold and Not Bold.
 
Did you actually select "Code Builder" so the code went into the report's
module?
How about sharing your results from your module?
 
Fred,

I don't think I put the code in the wrong place. Just in case, here is
exactly what I am doing:

Step 1: View report in design view
Step 2: Right Click on detail section and choose "Properties"
Step 3: I am now viewing the property sheet of the detail section.
Step 4: Click on Event tab.
Step 5: Click on the elipsis (...) to the right of the "On Format" section
of the Event Tab.
Step 6: I choose "Code Builder" from the Builder Message Box that pops up.
Step 7: I am now viewing Microsft Visual basic. There are two scroll boxes
at the top of the window. One says "Detail" and the other says "Format." In
the main area, I see:

Private Sub Detail_Format (Cancel As Integer, FormatCount As Integer)

End Sub

Step 8: I copy the code and paste it in between the two lines above. The
code I paste is:

Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c

The final result looks like this:

Private Sub Detail_Format (Cancel As Integer, FormatCount As Integer)
Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c
End Sub

Step 9: I save the code and close the code window.
Step 10: I save the report and click to open report view.

***There is no change in the font. I do not see alternating rows of font***

Am I cursed or is something else wrong? I'd appreciate any other help.
This is killing me...Thanks!

Glen



fredg said:
Hmm...it must be either something I am doing incorrectly or perhaps I did not
provide you with enough information. Here's what I did:

(1) Viewed report in design view
(2) Right-clicked on detail section
(3) Event Tab
(4) On-Format Section
(5) Pasted code

Information that may be useful:

(1) I have a colored background (not conditional formatting, just filled
text boxes). This is why I need to alternate between bold and normal font.

Thanks!

It appears you have placed the code in the wrong place.
All is well until (3) Event Tab.
On the Event tab, on the On Format line, write:
[Event Procedure]
Then click on the little button with 3 dots that appears on that line.
When the Code window opens, the cursor will be flashing between 2
lines of existing code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

End Sub

Between those 2 lines write:

Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c

Exit the window and save the report.
When you run the report the lines should alternate Bold and Not Bold.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.
 
Clifford Bass....You are MY HERO!!!! It was a very unconventional, but
creative way of helping me solve my problem. It worked perfectly. Thank
you!! And Thank you everyone else for your continued support!!!!! I'm going
to go home now and celebrate (I'm such a geek!!).

Glen
 
Uh oh....false alarm! I followed your instructions with conditional
formatting, but it has a conflict with my text boxes which are filled with
color. Once I apply the conditional formatting and I view the report, the
text boxes all lose their fill. Seems that the cond form takes precedence
over manual fill. Is there a solution to this? Looks like I will have to
hold off on my celebration ;(

Glen
 
OK Cliffford....almost there....When I choose the fill, I cannot find my
color on the color pallet when I go through conditional formatting. I am not
using a standard color. I cannot determine how to change the color pallet or
add a color to it so I can choose this color when applying conditional
formatting. Any ideas to help me jump over this last hurdle? New Year's Eve
is tomorrow and I want to be able to celebrate with my new database! Thanks!

Glen
 
Are you using Access 2007? Are you sure you are using the Print Preview? Did
you try to print the report?

Put a debug.print statement it so you can check the debug window to make
sure the code is running.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
debug.print c.Name & " Not Bold"
c.FontBold = True
Else
debug.print c.Name & " Bold"
c.FontBold = False
End If
Next c
End Sub

--
Duane Hookom
Microsoft Access MVP


*Glen* said:
Fred,

I don't think I put the code in the wrong place. Just in case, here is
exactly what I am doing:

Step 1: View report in design view
Step 2: Right Click on detail section and choose "Properties"
Step 3: I am now viewing the property sheet of the detail section.
Step 4: Click on Event tab.
Step 5: Click on the elipsis (...) to the right of the "On Format" section
of the Event Tab.
Step 6: I choose "Code Builder" from the Builder Message Box that pops up.
Step 7: I am now viewing Microsft Visual basic. There are two scroll boxes
at the top of the window. One says "Detail" and the other says "Format." In
the main area, I see:

Private Sub Detail_Format (Cancel As Integer, FormatCount As Integer)

End Sub

Step 8: I copy the code and paste it in between the two lines above. The
code I paste is:

Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c

The final result looks like this:

Private Sub Detail_Format (Cancel As Integer, FormatCount As Integer)
Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c
End Sub

Step 9: I save the code and close the code window.
Step 10: I save the report and click to open report view.

***There is no change in the font. I do not see alternating rows of font***

Am I cursed or is something else wrong? I'd appreciate any other help.
This is killing me...Thanks!

Glen



fredg said:
Hmm...it must be either something I am doing incorrectly or perhaps I did not
provide you with enough information. Here's what I did:

(1) Viewed report in design view
(2) Right-clicked on detail section
(3) Event Tab
(4) On-Format Section
(5) Pasted code

Information that may be useful:

(1) I have a colored background (not conditional formatting, just filled
text boxes). This is why I need to alternate between bold and normal font.

Thanks!

:

I copied and pasted Fred's code into the On Format event code in a report and
it worked as expected. I would probably add something that determines if the
control is a text or combo box so it doesn't attempt to change the fontbold
property of a line control.

I agree with Fred that changing the back color is more pleasing to the eye.

--
Duane Hookom
Microsoft Access MVP

:

I coded the detail section format event as per the instructions below for the
bold font, but there was no change when I viewed the report or printed it
out. Did I miss something or am I supposed to change any words in the coded
to match my control names?

:

On Mon, 28 Dec 2009 16:45:02 -0800, *Glen* wrote:

Can anyone tell me how to make the rows in my detail section of the report
alternate between bold font and normal font to make the report easier to
read? Thanks!

Glen

Code the Detail Section Format event:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c
End Sub

It might be easier to read if, instead of bolding every other line,
you alternated the back color of the detail section.

First make sure the BackStyle of each control is Transparent.

Code the Detail Format event:

If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 12632256 ' gray
Else
Me.Section(0).BackColor = vbWhite
End If

====
If you wish each page to start with a white row, code the Page Header
Format event:

Me.Detail.BackColor = 12632256 'Reset color to Grey so that the
first detail line will become white

Change the colors as needed.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.

It appears you have placed the code in the wrong place.
All is well until (3) Event Tab.
On the Event tab, on the On Format line, write:
[Event Procedure]
Then click on the little button with 3 dots that appears on that line.
When the Code window opens, the cursor will be flashing between 2
lines of existing code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

End Sub

Between those 2 lines write:

Dim c As Control
For Each c In Me.Detail.Controls
If c.FontBold = False Then
c.FontBold = True
Else
c.FontBold = False
End If
Next c

Exit the window and save the report.
When you run the report the lines should alternate Bold and Not Bold.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.
 
Glen, you can change the backcolor of the format conditions in the immediate
window.
1. Make sure you know the name of the controls, and the various conditions
that apply
2. Open the report in design mode.
3. In the immediate window try something like the following:

reports("reportname").Controls("control_name").formatconditions(0).backcolor
= rgb(255, 0, 0)

Use the RGB function or the long integer value to set the backcolor. This
should work for all the possible RGB values.
 
Glen,

Are you familiar with the difference between multi-posts and cross-posts?

What method are you using to post to the newsgroup? Are you using a web
based newsreader, Outlook Express, or some other method?

A lot of these methods have the ability to post as a cross-post, to more
than one group with a single message. The advantage of which is that
responses from any group will show up in all the groups. If you need help
with this, post back and one of use will help you out.
 
Alright...Duane showed me how to find the immediate window. The report name
is rptMatrix2_1. The control's name is personnel_2008. It still does not
work. Here is what I entered exactly as the code with all punctuation, etc:

reports("rptMatrix2_1").Controls("personnel_2008").formatconditions(0).backcolor
= rgb(197,236,255)
 
Back
Top