Change Color of a Command Button when Receives Focus?

  • Thread starter skyrise via AccessMonster.com
  • Start date
S

skyrise via AccessMonster.com

I have command buttons that receive focus based on a Tab Order. Right now it
is difficult to tell that cursor has “landed†on the button. I checked the
Properties list, but could not see anything that was specific to color
selection. Is there a way to change the color of the button when it receives
the focus (or some other event)?
 
L

Linq Adams via AccessMonster.com

You can't really change the color of the button itself, without doing a lot
of fancy dancing, but you can easily change the color of the Font and change
it to Bold when it has focus, which makes it obvious that it has focus:

Private Sub YourCommandButton_GotFocus()
YourCommandButton.FontBold = True
YourCommandButton.ForeColor = vbRed
End Sub

Private Sub YourCommandButton_LostFocus()
YourCommandButton.FontBold = False
YourCommandButton.ForeColor = vbBlack
End Sub
 
S

skyrise via AccessMonster.com

(TY: Linq Adams, alansidman [will use this in the future], and
pere_de_chipstick)

I’m working with command buttons as text (not as pictures). I was able to
use the following code that works when both tabbing onto the button and
clicking the button with the mouse pointer.

Private Sub GoToTab3_GotFocus()
GoToTab3.FontSize = 9
GoToTab3.FontBold = True
GoToTab3.ForeColor = vbRed
End Sub


Private Sub GoToTab3_LostFocus()
GoToTab3.FontSize = 10
GoToTab3.FontBold = False
GoToTab3.ForeColor = vbBlack
End Sub
 
Top