A couple of our teams here use a form I've set up to view all their files in one go. Until not I've always had conditional formatting to turn the "last chased" date to red if the date was more than 5 days in the past, however I've now been asked by one of the departments to change the "switchover" so that, just for their files, the "last chased" date changes to red if the date is more than 10 days old.
Obviously I can't use normal conditional formatting as I need to look up the department ID based on the user (it's stored already so no problems). I've done the following code, but it's not working right?
Incidentally, the code is sitting behind the Form_Current event of the subform (which is a continuous form) - I'm not sure it's in the right place....
Any ideas?
Cheers,
Ad
CODE
Private Sub Form_Current()
'Code fires on Form_Current. We have a login selected and can find out the department from this.
Dim strLogin As String, lngDepartment As Long
strLogin = Me.Login
'Find the department
lngDepartment = tLookup("StaffDepartment", "tblStaff", "Login='" & strLogin & "'")
Select Case lngDepartment
Case 4 'Tech & Legal
'It's Tech / Legal, so format based on 10 day cutoff
If Me.LastChased < AddDays(Today(), -10) Then
'Last chased is more than 10 working days ago - format accordingly
With Me.LastChased
.BackColor = vbRed
.FontBold = True
.ForeColor = 10092543
End With
Else
'Last chased date is less than 10 days old.
With Me.LastChased
.BackColor = 10092543
.FontBold = False
.ForeColor = vbBlack
End With
End If
Case Else
'Otherwise set it as 5 days...
If Me.LastChased < AddDays(Today(), -5) Then
With Me.LastChased
.BackColor = vbRed
.FontBold = True
.ForeColor = 10092543
End With
Else
With Me.LastChased
.BackColor = 10092543
.FontBold = False
.ForeColor = vbBlack
End With
End If
End Select
End Sub
'Code fires on Form_Current. We have a login selected and can find out the department from this.
Dim strLogin As String, lngDepartment As Long
strLogin = Me.Login
'Find the department
lngDepartment = tLookup("StaffDepartment", "tblStaff", "Login='" & strLogin & "'")
Select Case lngDepartment
Case 4 'Tech & Legal
'It's Tech / Legal, so format based on 10 day cutoff
If Me.LastChased < AddDays(Today(), -10) Then
'Last chased is more than 10 working days ago - format accordingly
With Me.LastChased
.BackColor = vbRed
.FontBold = True
.ForeColor = 10092543
End With
Else
'Last chased date is less than 10 days old.
With Me.LastChased
.BackColor = 10092543
.FontBold = False
.ForeColor = vbBlack
End With
End If
Case Else
'Otherwise set it as 5 days...
If Me.LastChased < AddDays(Today(), -5) Then
With Me.LastChased
.BackColor = vbRed
.FontBold = True
.ForeColor = 10092543
End With
Else
With Me.LastChased
.BackColor = 10092543
.FontBold = False
.ForeColor = vbBlack
End With
End If
End Select
End Sub