Label's On Mouse Move Event

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

I seem to remember some code that would trigger a change in a label's
property that would indicate the mouse pointer was over a label and back
again
when it moved off the label. Can't seem remember or find it anywhere.
Can anyone help me with this?

Thanks,
James
 
Set up a couple of temporary text boxes on your form to show the x and y
coordinates. move your mouse around and get the lowest and highest values
for x and y as they pass over the text box. Write them down and amend the
code below for your label.
Here is the code:

Private Sub Label2_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me!Text1 = X
Me!Text2 = Y

If (X > 0 And X < 1200) And (Y > 0 And Y < 240) Then
Me.Label2.Caption = "here"
Else
Me.Label2.Caption = "not here"
End If

End Sub

HTH
Damon
 
Maybe I didn't explain. I simply want, for instance, the BackColor of
the label to be one color when the mouse pointer passes over it and
another after the pointer moves off the label. Of course I'm using
the BackColor as an example. Sort of like command buttons do.
The code I remember was a simple if statement but I can't seem to remember.

James
 
Well, simply change my code from captions (Me.Label2.Caption =) to
me.label2.fontweight= 700 or what ever format property you want to control.

Damon
 
Sorry. I'd checked in Access 97 (only version on this machine), and there
are no events for labels. It must have been added since then.
 
Back
Top