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

Changing the backcolor of a field in a tabular form

Status
Not open for further replies.

egstatus

Programmer
Apr 14, 2005
143
US
Hi All,
I have an access form that I want to change the back color of the field I am in. I'm doing this in the got focus event and lost focus event. Unfortunately due to some requirements I need to display multiple record in the form at once.

Code:
Private Sub StateCode_GotFocus()
    Me.StateCode.BackColor = RGB(195, 214, 155)
End Sub

Private Sub StateCode_LostFocus()
    Me.StateCode.BackColor = RGB(217, 150, 148)
End Sub
The problem that I have is that the entire column changes its color. [See image below]
form_xo6flt.gif


How can I make just the field of the current record be the one with the green back color when the field gets the focus?

Thanks in advance

Ed
 
You need to use conditional formatting. There are several functions you can make to do it. What I do is put a hidden text box on the form called "txtSelected". Then on the forms current event set the value

me.TxtSelected = me.yTypeID

Then using conditional formatting you can make an expression like
TxtSelected = yTypeID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top