VBA code to change the border of objects on a form ... Got / Lost focus

sjs94704

Member
Local time
Yesterday, 22:58
Joined
May 7, 2013
Messages
41
All I want to do is create a VBA module that causes the border of a control, like a text box, to slightly change when it has the focus to prompt the user to help them know where they are on the screen. So, very simply, when a control gets the focus the border changes slightly but enough for the user to see to help them know where they are at!
 
Programmatically changing a control's properties affects ALL instances of control. So this doesn't really work for form in Continuous or Datasheet view. Consider using Conditional Formatting which can change the appearance of textbox and combobox individually for each record. Can't change border but can change background or font color or enable/disable. No VBA involved.

If form is in Single view or designed so only one record shows in Continuous view and you really want VBA, I expect would need code in both GotFocus and LostFocus events of each control.
 
Last edited:
you can also use Conditional Formatting on your Textbox to change it's color when it has focus.
like on the demo on form1.
 

Attachments

I really like what @Eugene-LS has done for highlighting active control.
No use of Conditional Formatting, not even a single line of code.

Pure control's properties.

 
Last edited:
KitaYama, I like that particular method as well but it unfortunately does not control the border color. That's the one disadvantage of that method. But like Eugene said, options are a good thing.
 
unfortunately does not control the border color
I know. And I didn't mention that method at first, because it wasn't what the OP was looking for.
Since there was some suggestions about Conditional Formatting (which can't handle borders), I thought it may help in some way.

Thanks for reminding.
 
What I am talking about is for data entry form. Not necessarily a continuous forms. Such as when entering customer or vendor name and addresses, etc..., but when it comes to continuous forms I get it that this would not work as mentioned previously!
 
I thought this question was already answered. Are you saying you still haven't got your border highlighting to work?
 
I thought this question was already answered. Are you saying you still haven't got your border highlighting to work?
Life shows up. I am in recovery and just got elected into a new position helping people in their first few days/weels of recovery, so my attention got diverted for a minute doing that! Just getting a moment to sit back down into my own life again and get back to this...

All I was trying to clarify is that I read in a post previous to this one that someone said that changing the color would not work in continuous forms, etc. and I was just clarifying that it was not my intent to do this in that type of form, that's all.
 
Last edited:
That's fine, I believe you have all the information you need from the previous comments. Just review the various recommendations and try to get it working.
 

Users who are viewing this thread

Back
Top Bottom