Solved

Mouse events changing the background color of labels

Posted on 2011-09-09
5
261 Views
Last Modified: 2012-06-21
I have some column headers on a continous form subform that when they are clicked on, it changes the sort order of the subform.  Pretty basic.

I would like to improve upon how they appear to the user.  What I have seen done, and would like to do, is have the background color of the label change when the mouse hovers over it.  I know how to make the color change, but I struggle with how to change it back.  In other words, if the back color of the label is white, I would like to change it to blue when the mouse is over it...then change back to white when the mouse leaves and hovers over another header which would then change to blue, etc, etc..

I can get it blue, but then it stays blue and I am not sure of what the customary way is to 'reset' it (change it back to white...)

0
Comment
Question by:snyperj
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
use the mousemove of the section where the label is, by calling a sub that resets all labels background to default..
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Use the mouseover event of the detail section of your form to "reset" the color of the label(s)
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
What I have found is that in order to reset the color, you have to use the mousemove event of the section the control is in, and possibly other controls surrounding it (especially if the labels are butted up against each other).  

So what you might do is (my colors are made up).

Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    me.label1.BackColor = RGB(255, 0, 0)
    me.label2.BackColor = RGB(255, 255, 255)

End Sub

Private Sub label2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    me.label1.Backcolor = RGB(255, 255, 255)
    me.label2.Backcolor = RGB(255, 0, 0)
    me.label3.Backcolor = RBG(255, 255, 255)

End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    me.label1.BackColor = RGB(255, 255, 255)
    me.label2.BackColor = RGB(255, 255, 255)
    me.label3.BackColor = RGB(255, 255, 255)

End Sub
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
there is no mouseover event for access form (afaik)
0
 

Author Closing Comment

by:snyperj
Comment Utility
Thanks- this matches closest to what I was struggling with.  I was using the section event but my labels are very very close together and the section itself is very short.... so I don't think the event was firing.  Placing the 'reset'  within each headers code is much more cumbersome, but gives the effect I was looking for.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now