Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change command button color on mouse hover 1

Status
Not open for further replies.

kgerlitz

Technical User
Oct 2, 2004
84
US
In VB code how can I get a command button to change colors when the mouse "hovers" over it.
 
Part number one, the command button background color cannot be changed from its amazing grey. Have you looked in the command button properties, events. I know it has a mouse down, mouse up, but don't think there's a mouse over. Welcome to Access. I have just moved over from VB to Access to do a project, I'm a bit worried with XP looking pretty my Access project will look as interesting as a dialogue box. I might be wrong. Maybe someone else can throw some good news for you.
 
kgerlitz
One thing you can do is use a text box, and shape it so that it looks like a command button.

Then change it's MouseOver property to the BackColor you wish.

Me.YourTextButton.BackColor = 16711680

Play around with that so that it changes when you move away from hovering over it.

Tom
 
Tom, evidently I did create a text box because of the color issue--that's the good news. However, the only mouse features I have under the events is Mouse Down, Move, and Up. I am working on Access 2000, could this be a later version thing?
 
So sorry. My mistake.

I meant to say MouseMove...not MouseOver.

What you have to do is add two codes - one to change it and one to change it back. Something like...
Code:
Private Sub YourTextBox_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Me.YourTextBox.BackColor = 16711680
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Me.YourTextBox.BackColor = 8388608
End Sub

Tom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top