Consulting

Results 1 to 2 of 2

Thread: Bold label when on focus

  1. #1

    Bold label when on focus

    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

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    As far as I know you cannot isolate an object's condition to one record on a continuous form, it is a bug that MS have never fixed.
    Many years ago I did see some complicated code that masks the records but that was using the background colour not the field's controls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •