Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form code for background color of controls 1

Status
Not open for further replies.

DJRobbieBAtl

Technical User
Jun 17, 2004
5
US
I am using the following code to change the backgroud color of a control when it has the focus, and then back to white when it doesn't have the focus.

Private Sub txtPounds_GotFocus()
Me.txtPounds.BackColor = RGB(255, 255, 128)
End Sub

Private Sub txtPounds_LostFocus()
Me.txtPounds.BackColor = RGB(255, 255, 255)
End Sub

Is there anyway to code the form when it loads to do this to all controls when they get focus and lose focus without actually writing the code to each control? Maybe a Function?

Any help would be greatly appreciated!

Thanks,
thedj
 
Welcome to Tek-Tips!
To get the most out of the membership, take a look at this faq faq181-2886.

If this is Access, and you're using version 2000+
1 - check out conditional formatting in the format menu, in the first combo, select "field has focus" and apply format
2 - check out the "pure" access fora found in the "Related Forums" box at the right

Should it be a userform in Excel, Word, I'm sorry, I haven't the foggiest, hope someone else might pop in;-)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top