I'm trying to create a dynamic way of highlighting an entire row when one of the textboxes is clicked.
The form consists of three textboxes PN, DE and MC and is configured for datasheet view.
The idea is that every control on the form is looped and checked to see if it is a textbox. If it is a textbox then a formatting condition is added to highlight the contents of the control based on the value of the textbox in the clicked row.
Here is the code so far and is triggered from the click event of any of the textboxes:
End Function
This is missing a lot of error capturing but I only wanted to get started!!
The trouble is that this only half works in that every time a row is clicked somewhere, only the PN row highlights.
Can anyone see why the other two cells are not highlighting. They all share the same code but for some reason once the first cell is highlighted, the others in the same row don't highlight.
Thanks
The form consists of three textboxes PN, DE and MC and is configured for datasheet view.
The idea is that every control on the form is looped and checked to see if it is a textbox. If it is a textbox then a formatting condition is added to highlight the contents of the control based on the value of the textbox in the clicked row.
Here is the code so far and is triggered from the click event of any of the textboxes:
Code:
Private Function click()
Dim ctrl As Control
Dim txtbox As TextBox
For Each ctrl In Me.Controls
If (StrComp(TypeName(ctrl), "textBox", vbTextCompare) = 0) Then
Set txtbox = ctrl
txtbox.FormatConditions.Delete
Call txtbox.FormatConditions.Add(acFieldValue, acEqual, Form(ctrl.Name).Value)
With txtbox.FormatConditions(0)
.BackColor = vbGreen
End With
End If
Next
End Function
This is missing a lot of error capturing but I only wanted to get started!!
The trouble is that this only half works in that every time a row is clicked somewhere, only the PN row highlights.
Can anyone see why the other two cells are not highlighting. They all share the same code but for some reason once the first cell is highlighted, the others in the same row don't highlight.
Thanks