Change a label's font color or background color with a mousemove event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmar93
    New Member
    • Mar 2008
    • 46

    Change a label's font color or background color with a mousemove event

    Hi,

    I am using Access 2007. I have a form in my database that I would like to have the font color or background color of some labels change when the cursor moves over them. Can anyone tell me how to do this?

    thanks,
    Jeff
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Labels do not respond to Events (they have none), so the only way to implement what you are requesting is to write code for the MouseMove() Events of the Text Boxes to which they are associated, and then to Reset the Fore Colors in the MouseMove() Event of the Detail Section of the Form, as in:

    When the Mouse Pointer passes over the Company and Contact Name Fields, the Fore Color of the associated Labels turn Green but as soon as the Pointer moves anywhere within the Detail Section, their Fore Colors revert to Blue. I know this isn't exactly what you were looking for, but it is just a suggestion.
    Code:
    Private Sub CompanyName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Me![CompanyNameLabel].ForeColor = vbGreen
    End Sub
    Code:
    Private Sub ContactName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Me![ContactNameLabel].ForeColor = vbGreen
    End Sub
    Code:
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Me![CompanyNameLabel].ForeColor = vbBlue
      Me![ContactNameLabel].ForeColor = vbBlue
    End Sub

    Comment

    • jmar93
      New Member
      • Mar 2008
      • 46

      #3
      This was exactly the info I needed, it solved my problem.

      Thank you very much.

      Jeff

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Actually, that's true of labels that are associated with textboxes (as most are in 2007) but independent labels do have a MouseMove event, as well as a few others.

        Linq ;0)>

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by missinglinq
          Actually, that's true of labels that are associated with textboxes (as most are in 2007) but independent labels do have a MouseMove event, as well as a few others.

          Linq ;0)>
          Good point Linq, and definitely one worth mentioning.

          Comment

          Working...