Changing label to Bold on Got Focus

  • Thread starter Thread starter Tara
  • Start date Start date
T

Tara

I need help changing a label to bold when it gets the
focus via OnMouseOver event and then going back to normal
weight when it loses focus. I'm sure there is an easy
way to do it, but I'm stuck.

Thanks in Advance!

Tara
 
You need to re-state your requirement. The label control
does not have a MouseOver event handler nor does it get or
lose focus.

Gerald Stanley MCSD
 
Sorry! I was in a hurry and didn't reread my post before
I sent it! Forget the lose focus stuff. What I need is
for the label text to go bold and then back to normal
using the On Mouse Move event. Hope that makes more
sense now!

Thanks
Tara
 
Hi Tara,

Well first off a label can never receive focus in the VBA sense so I'm
assuming you mean "when the mouse passes over this label change the font to
bold and then back to normal when you move the mouse away." Is this correct?

If so you need two events: one for the label itself and one for the detail
section (assuming this label is actually in the form's detail section).

This works for me:

Private Sub lblMyLabel_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lblMyLabel.FontBold = True
End Sub

Now to change it back to normal we need this code in the detail section:

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lblMyLabel.FontBold = False
End Sub

Passing the mouse over the label causes the font to go to bold and then
moving it away changes it back to normal. (You will have to use your own
label name of course)

HOWEVER, this will only work on unattached labels! I just recently found
this out from Dirk "Yoda" Goldgar. If you look at the Properties list for an
attached label there is no MouseMove event so the best thing is to just cut
it from the form, then paste it back on, and finally re-position it to where
you would like.

Hope that helps,
Jeff Conrad
Bend, Oregon
 
Back
Top