Color Code Report - Overdue

grainna

New member
Local time
Today, 12:38
Joined
May 7, 2010
Messages
1
Hi, this is my first post. I currently have a report that I color coded yellow if the due date is overdue or due in the next 60 days. I would like to change that to Red if Overdue and Yellow if due in the current month or the next 2 months.
I can not figure out how to add another condition. I am curretnly using Access 2000. Here is my current report set-up:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Const RED = 255
Const YELLOW = 65535
Const Blue = 65535
Const PINK = 65535
Const GREEN = 65535
Const WHITE = 16777215

If Me![DRYDOCK NEXT] < Now() + 60 Then
[DRYDOCK NEXT].BackColor = YELLOW
Else
[DRYDOCK NEXT].BackColor = WHITE
End If

If Me![LOAD LINE NEXT] < Now() + 60 Then
[LOAD LINE NEXT].BackColor = YELLOW
Else
[LOAD LINE NEXT].BackColor = WHITE
End If

If Me![LOAD LINE RENEWAL] < Now() + 60 Then
[LOAD LINE RENEWAL].BackColor = YELLOW
Else
[LOAD LINE RENEWAL].BackColor = WHITE
End If

End Sub

Thank you in advance for your help
 
Hi, this is my first post. I currently have a report that I color coded yellow if the due date is overdue or due in the next 60 days. I would like to change that to Red if Overdue and Yellow if due in the current month or the next 2 months.
I can not figure out how to add another condition. I am curretnly using Access 2000. Here is my current report set-up:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Const RED = 255
Const YELLOW = 65535
Const Blue = 65535
Const PINK = 65535
Const GREEN = 65535
Const WHITE = 16777215

If Me![DRYDOCK NEXT] < Now() + 60 Then
[DRYDOCK NEXT].BackColor = YELLOW
Else
[DRYDOCK NEXT].BackColor = WHITE
End If

If Me![LOAD LINE NEXT] < Now() + 60 Then
[LOAD LINE NEXT].BackColor = YELLOW
Else
[LOAD LINE NEXT].BackColor = WHITE
End If

If Me![LOAD LINE RENEWAL] < Now() + 60 Then
[LOAD LINE RENEWAL].BackColor = YELLOW
Else
[LOAD LINE RENEWAL].BackColor = WHITE
End If

End Sub

Thank you in advance for your help

Welcome to AWF!

Note: there are already constants for the colors. You also have several color defined as the same code.

Try this:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Me.[DRYDOCK NEXT].BackColor = vbWHITE
    
    If Me.[DRYDOCK NEXT] < Date() Then
        Me.[DRYDOCK NEXT].BackColor = vbRed

    ElseIf Me.[DRYDOCK NEXT] <= Date() +60 Then
        Me.[DRYDOCK NEXT].BackColor = vbYELLOW
    End If

    Me.[LOAD LINE NEXT].BackColor = vbWHITE
    
    If Me.[LOAD LINE NEXT] < Date() Then
        Me.[LOAD LINE NEXT].BackColor = vbRed

    ElseIf Me.[LOAD LINE NEXT] <= Date() +60 Then
        Me.[LOAD LINE NEXT].BackColor = vbYELLOW
    End If


    Me.[LOAD LINE RENEWAL].BackColor = vbWHITE
    
    If Me.[LOAD LINE RENEWAL] < Date() Then
        Me.[LOAD LINE RENEWAL].BackColor = vbRed

    ElseIf Me.[LOAD LINE RENEWAL] <= Date() +60 Then
        Me.[LOAD LINE RENEWAL].BackColor = vbYELLOW
    End If


    
End Sub
 

Users who are viewing this thread

Back
Top Bottom