Determine 'siblings' in form

OndraK

New member
Local time
Today, 14:48
Joined
Apr 11, 2013
Messages
1
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
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!
form.PNG
 
The trouble with using VBA in this instance, is that on a continuous form all records will be effected by the value held in the record that currently hold focus.

Have a look at Conditional Formatting.
 

Users who are viewing this thread

Back
Top Bottom