When I tab through the controls on a form, when a certain control has focus, how do I change that control's color. When It has focus I want to grab the users attention. I've searched for everything I could think of and can't find anything useful.
Donald is right - Conditional Formatting is the easiest way to do this. Set a rule for "Field Has Focus" and choose the background color, font color, etc. you want for that control.
You can apply it to most text boxes, combo boxes, and similar controls without writing any VBA.
Michael AlbertOP
@Reply 2 months ago
Excellent, thanks guys.
Michael AlbertOP
@Reply 2 months ago
Sorry, the control in question is a button. Conditional Formatting not available.
Any other thoughts?
Kevin Robertson
@Reply 2 months ago
Add this code to a Global Module.
DetailsPublic Function HighlightButton(ByVal HasFocus As Boolean)
Static btn As CommandButton
Static originalColor As Long
Static originalTheme As Long
Static originalTint As Single
Static originalShade As Single
Static originalGradient As Long
For a button, you can use its On Got Focus and On Lost Focus events to change the BackColor with a little VBA. Just keep in mind that it only fires when the button receives focus, such as when the user tabs to it. Hovering the mouse over it is a separate option available in the button's formatting properties.
Also, this approach isn't suitable for a continuous form. Changing the color of a control there changes it for every displayed record, not just the current row.
Michael AlbertOP
@Reply 2 months ago
Thanks guys, works like a charm.
Kevin Yip
@Reply 2 months ago
Some would prefer to have no tab stops for buttons ("Tab Stop" property set to No), and only tab stops for textboxes. This is to make sure the user clicks the buttons with the mouse, without accidentally activating the buttons with the keyboard. This is just a preference, of course, but something to think about. To make buttons stand out on a form, you could use its various color properties: HoverColor, HoverForeColor, PressedColor, PressedForeColor, etc.
Michael AlbertOP
@Reply 2 months ago
Thanks Kevin.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Developer 61.