?
Solved

Mouse events changing the background color of labels

Posted on 2011-09-09
5
Medium Priority
?
274 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36511247
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
ID: 36511264
Use the mouseover event of the detail section of your form to "reset" the color of the label(s)
0
 
LVL 49

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 36511306
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36511308
there is no mouseover event for access form (afaik)
0
 

Author Closing Comment

by:snyperj
ID: 36511767
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

749 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