DevilsSlide
Technical User
I want to use Conditional Formatting to visually alert users (Red, Yellow and Green).
I have a ComboBox on a Form that I want to display as 'Continuous Forms' that I want to apply Conditional Formatting. I understand that I can use Conditional Formatting from the Format Menu. But the ComboBox has several Text Values that I want to set Conditions for {Like: If tbl2Value = "tbl2V1" Or tbl2Value = "tbl2V2" Then BackColor = vbRed - See Sample Below}. The problem is when I use the AfterUpdate Event it applies the BackColor to the same color for all records regardless of value. I'd like it to apply to only the current record.
I think I could live with (the 1-default and 3-Optional Conditions) using the Conditional Formatting from the Format Menu if I can enter more than one text value per condition {Like: If Field Value is = "tbl2V4" or "tbl2V5" or "tbl2V6 or "tbl2V9" then FillColor = Yellow}. I've tried several combinations, but every one I've tried none seem to fit the condition so it rolls to the Default Format. I'm sure it can be done because on the same form I have another combo box with only 3 Text Values and can specify the format I need and it applies to only the current record.
I have the same problem when I try to hide objects of the form based on a check box of the current record. It Hides ALL or NONE - Not what I want.
Any Ideas or Suggestions?
Thanks
John
Current Code Snips:
Private Sub tbl2Value_AfterUpdate()
Dim lRed As Long, lYellow As Long, lGreen As Long
Dim lBlue As Long, lCyan As Long, lMagenta As Long
lRed = RGB(255, 0, 0)
lYellow = RGB(255, 255, 0)
lGreen = RGB(0, 255, 0)
lBlue = RGB(0, 0, 255)
lCyan = RGB(0, 255, 255)
lMagenta = RGB(255, 0, 255)
If tbl2Value = "tbl2V1" Or tbl2Value = "tbl2V2" Then
Me.tbl2Value.BackColor = lRed
ElseIf tbl2Value = "tbl2V3" Then
Me.tbl2Value.BackColor = lYellow
ElseIf tbl2Value = "tbl2V4" Then
Me.tbl2Value.BackColor = lGreen
ElseIf tbl2Value = "tbl2V5" Or tbl2Value = "tbl2V6" Then
Me.tbl2Value.BackColor = lBlue
ElseIf tbl2Value = "tbl2V7" Or tbl2Value = "tbl2V8" Or tbl2Value = "tbl2V9" Then
Me.tbl2Value.BackColor = lCyan
Else
Me.tbl2Value.BackColor = lMagenta
End If
End Sub
Private Sub tbl3Active_AfterUpdate()
If tbl3Active = -1 Then
Me.tbl2Value.Visible = True
Me.tbl4Note.Visible = True
Else
Me.tbl2Value.Visible = False
Me.tbl4Note.Visible = False
End If
End Sub
I have a ComboBox on a Form that I want to display as 'Continuous Forms' that I want to apply Conditional Formatting. I understand that I can use Conditional Formatting from the Format Menu. But the ComboBox has several Text Values that I want to set Conditions for {Like: If tbl2Value = "tbl2V1" Or tbl2Value = "tbl2V2" Then BackColor = vbRed - See Sample Below}. The problem is when I use the AfterUpdate Event it applies the BackColor to the same color for all records regardless of value. I'd like it to apply to only the current record.
I think I could live with (the 1-default and 3-Optional Conditions) using the Conditional Formatting from the Format Menu if I can enter more than one text value per condition {Like: If Field Value is = "tbl2V4" or "tbl2V5" or "tbl2V6 or "tbl2V9" then FillColor = Yellow}. I've tried several combinations, but every one I've tried none seem to fit the condition so it rolls to the Default Format. I'm sure it can be done because on the same form I have another combo box with only 3 Text Values and can specify the format I need and it applies to only the current record.
I have the same problem when I try to hide objects of the form based on a check box of the current record. It Hides ALL or NONE - Not what I want.
Any Ideas or Suggestions?
Thanks
John
Current Code Snips:
Private Sub tbl2Value_AfterUpdate()
Dim lRed As Long, lYellow As Long, lGreen As Long
Dim lBlue As Long, lCyan As Long, lMagenta As Long
lRed = RGB(255, 0, 0)
lYellow = RGB(255, 255, 0)
lGreen = RGB(0, 255, 0)
lBlue = RGB(0, 0, 255)
lCyan = RGB(0, 255, 255)
lMagenta = RGB(255, 0, 255)
If tbl2Value = "tbl2V1" Or tbl2Value = "tbl2V2" Then
Me.tbl2Value.BackColor = lRed
ElseIf tbl2Value = "tbl2V3" Then
Me.tbl2Value.BackColor = lYellow
ElseIf tbl2Value = "tbl2V4" Then
Me.tbl2Value.BackColor = lGreen
ElseIf tbl2Value = "tbl2V5" Or tbl2Value = "tbl2V6" Then
Me.tbl2Value.BackColor = lBlue
ElseIf tbl2Value = "tbl2V7" Or tbl2Value = "tbl2V8" Or tbl2Value = "tbl2V9" Then
Me.tbl2Value.BackColor = lCyan
Else
Me.tbl2Value.BackColor = lMagenta
End If
End Sub
Private Sub tbl3Active_AfterUpdate()
If tbl3Active = -1 Then
Me.tbl2Value.Visible = True
Me.tbl4Note.Visible = True
Else
Me.tbl2Value.Visible = False
Me.tbl4Note.Visible = False
End If
End Sub