Report Formating Code Question

S

scott04

Hi everyone,
I have a report that is formated every other line on the report for
alternating colors. See Code:
Private shadeNextRow As Boolean
Const shadedColor = 6723891
' Const shadedColor = 15726583 ' alternative shade colors
' Const shadedColor = 14078404
' Const shadedColor = 13356495
' Const shadedColor = 14281974
Const normalColor = 16777215
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Detail_Format_Error
' Choose a color based on the shadeNextRow value
If shadeNextRow = True Then
Me.Section(acDetail).BackColor = shadedColor
Else
Me.Section(acDetail).BackColor = normalColor
End If
' Switch the color for the next row
shadeNextRow = Not shadeNextRow
Detail_Format_Exit:
Exit Sub
Detail_Format_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Detail_Format_Exit
End Sub

In my database i was tracking the number of errors that were generated for a
lawsuit. Is there a way instead of formatting every other row a color,
formated it a different color if example there are more than 10 errors in the
record?? Any thoughts or suggestions is appreciated.
 
E

Evi

scott04 said:
Hi everyone,
I have a report that is formated every other line on the report for
alternating colors. See Code:
Private shadeNextRow As Boolean
Const shadedColor = 6723891
' Const shadedColor = 15726583 ' alternative shade colors
' Const shadedColor = 14078404
' Const shadedColor = 13356495
' Const shadedColor = 14281974
Const normalColor = 16777215
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Detail_Format_Error
' Choose a color based on the shadeNextRow value
If shadeNextRow = True Then
Me.Section(acDetail).BackColor = shadedColor
Else
Me.Section(acDetail).BackColor = normalColor
End If
' Switch the color for the next row
shadeNextRow = Not shadeNextRow
Detail_Format_Exit:
Exit Sub
Detail_Format_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Detail_Format_Exit
End Sub

In my database i was tracking the number of errors that were generated for a
lawsuit. Is there a way instead of formatting every other row a color,
formated it a different color if example there are more than 10 errors in the
record?? Any thoughts or suggestions is appreciated.

Do you mean the number of errors made by the report itself?
Or do you have a field that may say the word Error in it or something.
Please clarify.
If you are suing the designer of your database, do I dare to attempt to
answer your question? :)

Evi
 
S

scott04

Evi,
I am the designer of the database. The database tracks lawsuits in our
company. I have a query that calcutes the number of times an error is made
in a particular error and it sums the fields. I was wondering how to code
the on format to say if G2(this is the calcutaed field from my query) > 10
(with 10 being the number of error) then made this line in the report for
example RED.
 
E

Evi

Do you mean that whenever G2 reads a number >10, you want that line to be
red? If Yes:
..
In the OnFormat Event of the Detail section paste in:

IF Me.G2 >10 then
Me.Section(acDetail).BackColor =255
'red
Else
Me.Section(acDetail).BackColor=16777215
'white
End If



Evi
 

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