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