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.
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.