Unanswered: Highlight control only in current record
I have a continuous form and to help user's eyes am highlighting the control that is active using the code in GotFocus and LostFocus events:
Private Sub Highlight()
On Error Resume Next
Me.ActiveControl.BackColor = vbYellow
Private Sub UnHighlight()
On Error Resume Next
Me.ActiveControl.BackColor = vbWhite
The problem to be solved is having only the Control in the Current Record highlighted, not that control in all records visible.
I tried the following and it doesn't compile:
Conditional formatting does work. I was using the other technique from all my other forms. I'd hoped there was a way to save redoing everything in this one.
OK, next question: I have one button that is in the tab sequence and want to highlight that in turn. My old method wouldn't change the background, and conditional formatting is not available with buttons. Even manually changing the background color in the button's property sheet didn't seem to do anything.
Instead create a text box control with the control source set to your button text (="ButtonAction"), set it to Locked to prevent editing and have it mimic a buttons action by placing the same code you have for the button in the on click event and also the KeyDown event to capture Enter key action.
Private Sub Text12_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
It's not great, but will allow you to use conditional formatting.
Thanks, for the additional idea. What I decided to do was to bump the FontSize from 6 to 7 and the FontWeight property from 400 (normal) to 700 (bold). This provided a visible change that worked nicely:
Private Sub btnSameAsBotan_GotFocus()
Me.ActiveControl.FontSize = 7
Me.ActiveControl.FontWeight = 700
Private Sub btnSameAsBotan_LostFocus()
Me.ActiveControl.FontSize = 6
Me.ActiveControl.FontWeight = 400
Access is a great program, but Microsoft doesn't see it as a money winner and so never makes serious changes that so many people want to see. It would be great it MS sold it to someone who really cared and listened to the users and made changes that really matter like allowing controls to be changed as you are trying to do.