Unpredictable color

S

Song Su

I use following code in all of my reports. For some reports, first record
shows as green. For other reports, first record shows as white.
unpredictable.

If I want all of my reports' first record to be green, how to do it?

thanks.

Private m_RowCount As Long
Private Sub Detail_Format(CANCEL As Integer, FormatCount As Integer)

m_RowCount = m_RowCount + 1
If m_RowCount / 2 = CLng(m_RowCount / 2) Then
Me.Detail.BackColor = 16777215 'white color
Else
Me.Detail.BackColor = 13303754 'green color
End If
End Sub
 
R

RoyVidar

Song Su said:
I use following code in all of my reports. For some reports, first
record shows as green. For other reports, first record shows as
white. unpredictable.

If I want all of my reports' first record to be green, how to do it?

thanks.

Private m_RowCount As Long
Private Sub Detail_Format(CANCEL As Integer, FormatCount As Integer)

m_RowCount = m_RowCount + 1
If m_RowCount / 2 = CLng(m_RowCount / 2) Then
Me.Detail.BackColor = 16777215 'white color
Else
Me.Detail.BackColor = 13303754 'green color
End If
End Sub

I don't know, but I *guess* one reason could be that the Detail
sections on format event fires more than once. To be entirely
sure, I think I'd

1 - add a line to the reports on open event, initializing the
module level variable to 0

m_RowCount = 0

2 - ensure the increment of the counter, and the colour toggling
only occurs one time per each row (each time the details on
format event fires)

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

If FormatCount = 1 Then
m_RowCount = m_RowCount + 1
If m_RowCount / 2 = CLng(m_RowCount / 2) Then
Me.Detail.BackColor = 16777215 'white color
Else
Me.Detail.BackColor = 13303754 'green color
End If
End If
End Sub

Another thing to look for - could you by any chance have a public
variable named m_RowCount? If so, and if you forget to declare
one in the report class module and forget to initialize it in the
reports on open, you might get the publics value as start value.
 
S

Song Su

I just discovered that whenever I have even number of records show up, it
starts as green. Same report, if odd number of records show up, it start
white.

Any idea how to start with green no matter even or odd number or records?

Thanks.
 

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

Similar Threads


Top