Consulting

Results 1 to 2 of 2

Thread: outline which control currently has the focus

  1. #1

    Question outline which control currently has the focus

    This isn't for a userform, btw.

    The document uses activex textboxes, checkboxes and listboxes on it. I have the property for the borderstyle for each control set to 'none'. I would like to have it so whenever each control has the 'focus', it will change the property for the borderstyle to 'single'. Then, as it loses the control it will switch back to 'none'.

    I already have some code that if something is entered (or checked, if its a checkbox, or chosen if its a list box) where it changes the background color to yellow. If its blank or null, it goes back to white. Example of how the current code looks for one of the textboxes:

    Private Sub txtName_Change()
    If txtName.Value = "" Then txtName.BackColor = &H80000005 Else txtName.BackColor = &HFFFF&
    End Sub
    Since the border is default to 'none' for each of the controls, it can be difficult sometimes to see exactly where (in what box) the cursor is currently flashing indicating that that control has the focus. It would be much easier to locate which control if instead the entire outline of the control would be visible via the 'single' line aound it.

    Thanks for the help!

  2. #2
    I figured it out. (as usual I was over-complicating things and over=thinking this.)

    Private Sub txtOtherReg_GotFocus()
    txtOtherReg.BorderStyle = fmBorderStyleSingle
    End Sub
    Private Sub txtOtherReg_LostFocus()
    txtOtherReg.BorderStyle = fmBorderStyleNone
    End Sub

Posting Permissions

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