• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

MS Access Reports GreenBar or Muliptile color lines

IN my report, I hide the details, but summarized the group results. I'm trying to create a greenbar affect where each other line has a different color. I found this code and tried it, it's not working correctly.

Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount As Integer)
Dim intCounter As Integer

intCounter = intCounter + 1
If intCounter Mod 2 = 0 Then
    Me.Section(0).BackColor = "16777215"
Else
    Me.Section(0).BackColor = "8454143"

End If

End Sub
0
jumpy262000
Asked:
jumpy262000
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Lebans has it:

http://www.lebans.com/Report.htm

One of the apps ..

mx
0
 
Rey Obrero (Capricorn1)Commented:
jumpy262000,

you need to create a control name txtLineNum with it's
source =-1, Running Sum - Overall.
visible=NO

If (Me![txtLineNum] Mod 2) = 0 Then

    Me.Section(0).BackColor = "16777215"
Else
    Me.Section(0).BackColor = "8454143"

End If
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
For your original code, try using the Format event instead.

mx
0
 
LambertHeenanCommented:
You don't even need the running sum control on the report. All you really need is a static Boolean variable in the Detail section's Format Event...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Static bShaded As Boolean
    If Detail.HasContinued = False Then bShaded = Not bShaded
    If bShaded = False Then
        Me.Detail.BackColor = BGLightGray
    Else
        Me.Detail.BackColor = BGwhite
    End If
End Sub

the line "    If Detail.HasContinued = False Then bShaded = Not bShaded" ensures that if a row of data spans two pages, each part will have the same colors.

BGLightGray and BGwhite are just two constants declared elsewhere that define the colors to use.

HTH

Lambert
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now