Hello, I been using the VBA I found to highlight a control that has focus and it works great except I want to have the controls label be bold also. I also wanted to know how to be able to use this in the continuous portion of a form without it highlighting every control in each row that has the same control name.
'======================================================================================
'Each Control will need “HighlightOnFocus” in its Tag property. and called from forms
' OnLoad Event using SetFocusHandlers Me
'======================================================================================
Public Function SetFocusHandlers(ByRef frm As Form)
Dim ctl As Control
For Each ctl In frm
If ctl.Tag = "HighlightOnFocus" Then
ctl.OnGotFocus = "=HandleFocus([" & ctl.Name & "], True)"
ctl.OnLostFocus = "=HandleFocus([" & ctl.Name & "], False)"
End If
Next
End Function
Public Function HandleFocus(ByRef ctl As Control, ByVal blnFocus As Boolean)
If blnFocus = True Then
ctl.BorderColor = RGB(255, 0, 0)
ctl.BorderWidth = 2
Else
ctl.BorderColor = RGB(122, 138, 153)
ctl.BorderWidth = 1
End If
End Function