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
.