highlight labels on mouse move

S

Silvio

I would like to improve my form navigation with some visual effect. The form
has several command buttons with the unbounded label next to it. I would like
to create a highlight like effect when the user moves over a label with the
mouse. This is what I have done so far:

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, x As
Single, Y As Single)
lblReports.BackColor = 16777215
End Sub

The problem I am having is that once I move over to a different label with
the mouse, the previous label does not go back to normal and retains the
highlight effect.

How can I solve this problem?
Is there a better way to accomplish what I am trying to do since my form has
15 different labels?

Please be specific…

Thank you,
Silvio
 
L

Linq Adams via AccessMonster.com

Here's a tutorial on using the MouseMove property that just happens to do the
very thing of which you speak:

http://bytes.com/topic/access/insights/648549-using-mousemove-property

You have to set the formatting for each control in its own MouseMove event.

You "reset" the formatting to the default by "reversing" the formatting in
the ***section's*** MouseMove event. If the control resides on the Detail
section, you do it in the Detail's MouseMove event. .
 
D

Damon Heron

First, rename all your labels lbl1,lbl2,lbl3, etc.
Then, in the form's Open event,
Private Sub Form_Open(Cancel As Integer)
Dim strControlName As String
Dim x As Integer
For x = 1 To 15
strControlName = "lbl" & CStr(x)
Me(strControlName).OnMouseMove =
MakeFunctionCall("HandleOnMouseMove",strControlName)
Next x
End sub

'add this function
Private Function HandleOnMouseMove(ByVal strThisControlName As String)
Me(strThisControlName).BackColor = vbRed

'Then in the form's detail event,
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim strControlName As String
Dim Z As Integer

For Z = 1 To 15
strControlName = "lbl" & CStr(Z)
Me(strControlName).BackColor = vbWhite
Next Z
End Sub

I used vbRed and vbWhite just for me, you can substitute whatever.

Damon
 
S

Silvio

Thanks guys this works just fine. However, I do have a question about this.
My form with the menu, has also a subform and I noticed that when the focus
goes to the subform the last label highlight stays on and I think it should
go off. Is there anything that can be done to turn it off once I move the
focus away from the main form to the subform?
 
D

Damon Heron

Haven' t tested, but you might try the OnEnter event for the subform (which
is found on the main form's list, not the subform) .

Damon
 

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