Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2005
    Posts
    46

    Unanswered: Mouse move on a label

    I want to change the background colour of a label when the mouse is hovering over it. When the mouse is not over the label I then want the background colour to change back to the original colour.

    I have tried using the mouse move event on the label box which seems to change the colour but I don't know how to revert it back again to its original colour/

    Any ideas

  2. #2
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    Don't think you can. You can change the backgroud colour in response to some criteria or you could use control tip text.

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Sure you can, Cornish! To change the color back when the mouse moves off of the label, you set it to the original color in the Private Sub Detail_MouseMove!

    Code:
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
         YourLabel.BackColor = vbWhite ' or whatever color it originally was
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Oct 2006
    Posts
    110
    I am also trying the same function, but on border color, I understand how the color is applied on the mouse over the label, but when the mouse moves off the label, how do we get the color to change back to its original color before the mouse moved over it the first time?

    Thanks
    Chris

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Read my post just prior to yours! You change the color (whichever color you're concerned with) back in the Private Sub Detail_MouseMove sub. Just replace .BackColor with whichever property you're changing! When you move off of the label and over the Detail section of the form the color will be reset.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Oct 2006
    Posts
    110
    when you say backcolor, your referring to the background color of the label, not it reverting back to its previous color, thats what I meant. I am doing borders, not background colors of labels.

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    The sample code I posted showed how to reverse (set colors back to their original state) the MouseMove effect. It happened to use the .BackColor property, but you could use it to reverse the MouseMove effect for .BorderColor as well, or any other format property of the label!

    Say you have a label named MyLabel. You want its normal state to have a white border, then when the mouse moves over the label have the border turn red. If you use this to change the border color to red on a label named MyLabel:

    Code:
    Private Sub MyLabel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
         MyLabel.BorderColor = vbRed
    End Sub
    to return the border color to white you'd use this:

    Code:
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
         MyLabel.BorderColor = vbWhite 
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    Good one Missinglinq. You learn something every day.

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That's why we're all here!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •