Count Property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to modify the look of certain controls depending on their value (ie.
highlight the bad ones).

Using both the Detail_Format & Detail_Print Events I discovered that the
"Me.Detail.Controls.Count" property always has a zero(0) in it regardless of
the number of controls on the detail line of the report. Is there anyway to
populate this property?

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim i As Integer
Dim stwk As String

* Me.Detail.Controls.Count = 0
* Code Does Not Execute
For i = 0 To Me.Detail.Controls.Count - 1
stwk = Left(Me.Detail.Controls(i).Name, 17)
If stwk = "CurrYrFailureRate" Then
If Me.Detail.Controls(i).Value > 19.9 Then
Me.Detail.Controls(i).BackStyle = 0
Me.Detail.Controls(i).BorderStyle = 0
Else
Me.Detail.Controls(i).BackStyle = 1
Me.Detail.Controls(i).BorderStyle = 1
End If
End If
i = i + 1
Next

End Sub

Thanks for Your Help; Dean
 
Hi.
Is there any reason you would not use the condtional formatting property. I
have used that and found it to meet most needs.
Hope this helps.
Fons
 
Found the answer. In reviewing MS Help files I noticed they didn't use the
"Count" property they used the "For Each" command instead. Gave it a try and
it worked. Here's the code:

For Each cntl In Me.Detail.Controls
stwk = Left(cntl.Name, 17)
If stwk = "CurrYrFailureRate" Then
vaValue = cntl.Value * 100
If vaValue > 19.9 Then
cntl.BackStyle = 1
cntl.BorderStyle = 1
Else
cntl.BackStyle = 0
cntl.BorderStyle = 0
End If
End If
Next cntl
 
Back
Top