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

Changing Back Color on One field

Status
Not open for further replies.

rockiwood

MIS
Apr 17, 2002
50
GB
I am using a form in Continuous Forms Mode. I would like to make the control a different color on each record, depending on the selection.
Using the following code, I can get the color to change on ALL records that are showing but not the correct color for each record, i.e. Record 1 may be Down Crew and Record 2 may be Down Weather but all controls will be Green or all controls will be Yellow.
I have also attempted using this code in Form Current with the same results.

I would appreciate any help. I am a beginner programmer.


Thanks....jerry

Private Sub cboReason_BeforeUpdate(Cancel As Integer)

' Selects which color the Combo Box [cboReason] should be when a selection is made.
Dim strColorReason As String
Dim clrRed As Long
Dim clrBlue As Long
Dim clrYellow As Long
Dim clrGreen As Long

If Not IsNull(Me.cboReason.Value) Then
strColorReason = Me.cboReason.Value
Else
Exit Sub
End If

clrRed = RGB(255, 100, 0)
clrBlue = RGB(0, 150, 255)
clrYellow = RGB(255, 255, 0)
clrGreen = RGB(0, 255, 0)

Select Case strColorReason
Case "Down Weather"
Me.cboReason.backcolor = clrGreen
Case "Down Maintenance"
Me.cboReason.backcolor = clrRed
Case "Down Crew"
Me.cboReason.backcolor = clrYellow
Case "Call-by-Call"
Me.cboReason.backcolor = clrBlue
Case Else
Exit Sub
End Select

End Sub
 
If you have Access 2000, then you can use conditional formattting which works for continuous forms. Select the field and go to format on the menubar. I believe it allows up to 3 criteria per field.
 
Hi,

If you're using Access 97 you've run into a nice little problem. Give me your email and I'll send you the sample database I used to fix this little problem. Salvatore Grassagliata
GrassagliataS@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top