Hey guys,
I am fighting with one problem (Please see screenshot first). I need to set yellow backgroud of rows with specific property (e.g. if [ID] mod 2=0 - does not matter at all). But when i try to do this with VBA i am not able to set backcolor only for some rows. I can loop through all controls, determine type of control and set backcolor - but which property helps me determine if they are in the right row. Here is my code
I am fighting with one problem (Please see screenshot first). I need to set yellow backgroud of rows with specific property (e.g. if [ID] mod 2=0 - does not matter at all). But when i try to do this with VBA i am not able to set backcolor only for some rows. I can loop through all controls, determine type of control and set backcolor - but which property helps me determine if they are in the right row. Here is my code
Private Sub ID_Click()
Dim ctrl As Control
If [ID] Mod 2 = 0 Then
For Each ctrl In Me.Controls
If (ctrl.Top = ID.Top) Then
Debug.Print (TypeName(ctrl))
If (TypeName(ctrl) = "TextBox") Then
ctrl.BackColor = vbYellow
End If
End If
Next
End If
End Sub
Thanks a lot!Dim ctrl As Control
If [ID] Mod 2 = 0 Then
For Each ctrl In Me.Controls
If (ctrl.Top = ID.Top) Then
Debug.Print (TypeName(ctrl))
If (TypeName(ctrl) = "TextBox") Then
ctrl.BackColor = vbYellow
End If
End If
Next
End If
End Sub