Count Property

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

Guest

I want to modify the backstyle and the Borderstyle properties of certain
controls on the detail line of a report depending on the value of a field. I
have tested the code (below) on both the Detail_Format and the Detail_Print
Event. In both cases the Me.Detail.Controls.Count is zero. Even though
their are 40 or 50 controls within the detail line of this report. Any
thoughts would be appreciated.

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

Dim i As Integer
Dim stwk As String


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
 
I tested:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
MsgBox Me.Section(0).Controls.Count
End Sub
This gave me the correct number of controls in the detail section.
Me.Detail.Controls.Count also worked.
 
thedeanslist said:
I want to modify the backstyle and the Borderstyle properties of certain
controls on the detail line of a report depending on the value of a field. I
have tested the code (below) on both the Detail_Format and the Detail_Print
Event. In both cases the Me.Detail.Controls.Count is zero. Even though
their are 40 or 50 controls within the detail line of this report. Any
thoughts would be appreciated.

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

Dim i As Integer
Dim stwk As String


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

This problem occurs in an A97 database when it's running on
a Win NT, 2000 or XP system.

Either use Me.Controls (all the ones on the form) or use a
For Each loop.
 
Back
Top