Graying of alternate lines of a report

J

Jim Benson

I have an Access report the uses the below code to "gray" alternate lines of
a report. Worked fine on Access 2000 but in 2003 it doesn't work. What is
the problem.

Thanks,

Jim Benson

Private mfGray As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Call AlternateGray
End Sub

Private Sub AlternateGray()

' If the current section is to be printed in gray,
' then set the BackColor property for the section.
' This works only because the controls on the section
' are all set to be transparent.

Me.Section(acDetail).BackColor = _
IIf(mfGray, vbMenuBar, vbWhite)

' Next time, do it the opposite of the way
' you did it this time.
mfGray = Not mfGray
End Sub
 
M

Marshall Barton

Jim said:
I have an Access report the uses the below code to "gray" alternate lines of
a report. Worked fine on Access 2000 but in 2003 it doesn't work. What is
the problem.


Private mfGray As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Call AlternateGray
End Sub

Private Sub AlternateGray()

' If the current section is to be printed in gray,
' then set the BackColor property for the section.
' This works only because the controls on the section
' are all set to be transparent.

Me.Section(acDetail).BackColor = _
IIf(mfGray, vbMenuBar, vbWhite)

' Next time, do it the opposite of the way
' you did it this time.
mfGray = Not mfGray
End Sub


Don't know why that ever worked. Get rid of the mfGray
variable, record to record calculations are just not a valid
approach.

I think all you need is:
If Me.Section(acDetail).BackColor <> vbWhite Then
Me.Section(acDetail).BackColor = vbWhite
Else
Me.Section(acDetail).BackColor = vbMenuBar
End If
 

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