Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Command Button Hover Color

Posted by: MVarner Mar 21 2012, 04:01 PM

Is it possible to change the hover color of a command button in Access 2010 using VBA or a Macro. I can't seem to fine a property for that anywhere. If so can someone tell me how?
arshall

Posted by: RJD Mar 21 2012, 06:44 PM

Hi Marshall: Here's one way to do it (I'm sure there must be others). In this demo the command button is retained, but made transparent. A label is slipped underneath and sent to the back. Then the Mouse Move event of the command button is used to change the Back Color of the label to red (just an optional color here as an example). The detail section Mouse Move event is used to change color label back to gray.
Is I say, no doubt there are other ways, but I like to keep the command button and do the color with the label underneath.
HTH
Joe

 CommandButtonHoverColor.zip ( 13.55K ): 71
 

Posted by: RJD Mar 21 2012, 06:58 PM

Hi again: Here's another demo - it adds a technique of just using the label, without the command button over the top. You have to adjust the text spacing, visual format, etc. to do this, but accomplishes essentially the same thing with one object.
oe

 CommandButtonHoverColor2.zip ( 20.81K ): 74
 

Posted by: missinglinq Mar 21 2012, 08:18 PM

And just so that you know, Marshall, the only really practical way to do this is using some variation on those that Joe has given you. The BackColor of Command Buttons is one of those things that has to be set through Windows, and effects all Command Buttons in all Windows-compliant apps on the machine. Only the Fore (text) Color of a Button can be manipulated using VBA.
Linq ;0)>

Posted by: theDBguy Mar 21 2012, 08:31 PM

Hi Marshall,
ardon me for jumping in... but for Acc2010, you can use the "Hover Color" property to change the color of the button when the mouse is placed on top of the button and use the "Pressed Color" property to change the color of the button when the user clicks on it.
Just my 2 cents... 2cents.gif

Posted by: RJD Mar 21 2012, 08:55 PM

Very good call DBguy. I almost always use A2007 and hadn't tested with A2010 (on another machine awaiting SP2). But you are certainly correct - with A2010 (just looked at) the "Hover" color features have been added. Much better solution if app is to be run exclusively on A2010 - and I should have caught that he was using A2010.
egards,
Joe

Posted by: missinglinq Mar 21 2012, 09:12 PM

Well hush my mouth, as we say down South! What will the Access Gnomes think of next? Maybe fixing some of the bugs that have been around for over a decade? Oh, no, that would make too much sense!
Linq

Posted by: MVarner Mar 22 2012, 03:20 PM

Thanks for all the great responses. I have decided which option to use just yet but it always nice to have options.
Marshall

Posted by: theDBguy Mar 22 2012, 03:46 PM

Hi Marshall,
Joe, Linq, and I are all happy to help. Good luck with your project.

Posted by: Pigeon Pie Aug 13 2019, 09:37 PM

me.[CONTROL NAME].properties("hovercolor") = rgb(100,200,100)

Posted by: theDBguy Aug 13 2019, 10:04 PM

Hi. Welcome to UA! welcome2UA.gif

Just FYI, you are posting on a very old thread (over 7 years).