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!

Field Highlighting

Status
Not open for further replies.

csegal

Technical User
Jun 12, 2001
38
US
I am using Access 97,
Is it possible to highlight a field as I toggle through the form. For instance, the current field background color is WHITE. When I select a field I would like it to be light BLUE or YELLOW etc... then when toggled to the next field the previous fiels goes back to WHITE and the next field becomes highlighted to whatever color.

Thanks
csegal@arrowair.com
 
Use the gotfocus and lostfocus events to change the backcolor property
 
This will do what you're looking for. It turns the field yellow:

Insert the following code into the OnGotFocus event procedure for a field:

Private Sub txtAssignedTo_GotFocus()

Highlight ("GotFocus")

End Sub

Insert the following code into the OnLostFocus event procedure of the field:

Private Sub txtAssignedTo_LostFocus()

Highlight ("LostFocus")

End Sub


Insert the following code into a module:

Function Highlight(Stat As String) As Integer

Dim ctrl As Control

On Error Resume Next

Set ctrl = Screen.ActiveControl

If Stat = "GotFocus" Then
ctrl.BackColor = 65535

ElseIf Stat = "LostFocus" Then
ctrl.BackColor = 16777215

End If
End Function
Linda Adams
Linda Adams/Emory Hackman Official Web site Official web site for actor David Hedison:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top