Label's On Mouse Move Event

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
 
D

Damon Heron

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
 
J

JamesJ

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
 
D

Damon Heron

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
 
D

Douglas J. Steele

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top