Changing Textbox Colors

Rupert Bennett

Active Member
Joined
Nov 20, 2002
Messages
274
Hello Everyone,
I have what I hope is a simple question. It is always tough when you don't know how.

I would like to change the textbox Backcolor when they have focus and when they have lost focus. I have something that works now, but it is a tedious exercise when you need to make changes and you have many textboxes.
I have in each textbox GotFocus Event e.g. Text1.BackColor = RGB(117,225,257)
and iin the LostFocus Event Text1.BackColor = RGB(225,225,0)

Can you give me some code , Global or at the Form level, that will do this for each textbox on the form? This would be a lot more effecient.
Thanks for helping.
Rupert
 
Options -
post a link to where you found the file
you have a Google account? Then you have a drop box there to which you can post a link to the file
We've never been allowed to post files here for as long as I've been lurking herein.
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I haver also asked in another forum I frequent and this is the thread.


@Micron I had to join the Access User Group to get a link to the file.
I have now uploaded it to my Google drive and here is the link
 
Upvote 0
Seems I misunderstood some of what you are asking when talking in the other forum.
The easiest simple method would be to use a common public function and put that in the events

=GotFocusBackcolor()
or =LostFocusBackColor()

and have the relevant code snippet in in those functions.
 
Upvote 0
I found that this can be done without the need for any VBA code at all. You just need to assign the textbox the color you need it to show when it has focus and then set the BackStyle to Transparent. This works well , particularly if the form has a light colored backgrould. With a dark background form, Conditional Formatting works perfectly. I got this tip from a video by Karl Donaubauer on his site at Isladogs on Access I hope I am not violating any forum rules by listing this site. It has been many years since my last post.
 
Upvote 0
That is not his site, but isladogs.
However if you have a solution, that is all that matters.
Care to provide the actual link?
 
Upvote 0

Forum statistics

Threads
1,216,499
Messages
6,131,012
Members
449,613
Latest member
MedDash99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top