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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing backcolor for ALL controls on a form 3

Status
Not open for further replies.

Kobayashi

Technical User
Oct 11, 2001
69
US
I would like to know if anybody has a general function which can be used, perhaps in the form's OnLoad or OnOpen event, to change the backcolor of all controls on a form depending which control currently has the focus, without having to add an event to each individual controls OnGotFocus event?
I thought I had found the answer a couple of times from this site but not quite.

I guess the function will contain the Dim ctr As Control and For Each ctr statements, but after that I'm lost I'm afraid.

Many thanks in advance.

Adrian
 
Adrian,

I like Jim's option of giving the users choices on their color schemes.

In cases where you have textboxes that don't share the same default color, you could also use the tag property to define the default color.

A pop up form could be used for selecting alternate colors and selections could change the tag property.

Code:
ctl.backcolor = ctl.tag


HTH
John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top