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

change field background colour on focus

Status
Not open for further replies.

seat172

Technical User
Mar 1, 2002
1
GB
Hi guys, got my database sorted but one of my user wants the index field and the data entry field in my form to change colour on the entry field getting focus. Index field is named index, (original hu?) the data entry field is named count.

Many Thanks
 

seat172,

I suggest using conditional formatting. Right click on the field.

PMB [noevil]
 
I think the post means that on a form, when the cursor is in the key field, to have that text box change color.

This is very easy. I use a function to change the border color around text boxes as they get the focus, to help the eye see where the cursor is. I start with a 1 or 2 pt white border around a blue background with white text. When the field has the focus, I change the border color to RED. When it loses focus, I change it back to White.

You could easily do the same thing for the BACKGROUND, just remember to set it back to the 'standard' color, and also be careful of changing the text color too... I guess it would depend on WHAT colors your client wanted. Here's the functions I use - just tie them to the ON GOT FOCUS and ON LOST FOCUS events of any control you want:

Code:
Function ResetBorderColor()
  On Error Resume Next
  Screen.ActiveControl.BorderColor = vbBLACK
End Function

Function ResetBorderWhite()
 On Error Resume Next
 Screen.ActiveControl.BorderColor = vbWhite
End Function

Function SetBorderColor()
 On Error Resume Next
 Screen.ActiveControl.BorderColor = vbRED
End Function

For example, start with a border color of white. On a field, in the property sheet, set its' GOT FOCUS event to
=SetBorderColor()

Set it's LOST FOCUS event to
=ResetBorderWhite()

Feel free to mix and match whatever colors you want...

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top