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

I want to change the colors of a field based on the contents 1

Status
Not open for further replies.

mrgrogro

Technical User
Jan 8, 2005
58
0
0
US
I want to change the back and fore colors of a field based on the PrepStatus field's value. This is an import from an AS400 that was exported to excel. This is my code but it doesn't work.

Private Sub Form_Open(Cancel As Integer)

If Me.PrepStatus.Value = "AT PRESS" Then
Me.PrepStatus.BackColor = 16384
Else: Me.PrepStatus.BackColor = -2147483633

End If

If Me.PrepStatus.Value = "AT PRESS" Then
Me.PrepStatus.ForeColor = 16777215
Else: Me.PrepStatus.ForeColor = 0
End If

If Me.PrepStatus.Value = "AT PLATES" Then
Me.PrepStatus.BackColor = 65280
Else: Me.PrepStatus.BackColor = -2147483633
End If

If Me.PrepStatus.Value = "AT PLATES" Then
Me.PrepStatus.ForeColor = 16777215
Else: Me.PrepStatus.ForeColor = 0
End If

End Sub

"PrepStatus" is the name of the field. "AT PRESS" and "AT PLATES" are possible field values but not all values possible. This code is currently in the "on open" and "on current" events. What am I doing wrong? Any help would be appreciated.

Thanks in advance.
 
Oops, I forgot to mention this was for Access 2000.

Thanks, kp
 
Use the Current event procedure of the form and a Select Case instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top