RCheesley
Registered User.
- Local time
- Today, 03:47
- Joined
- Aug 12, 2008
- Messages
- 243
Hi all,
Wonder if you can help, I'm trying to get text boxes to conditionally format depending on the dates which are updated automatically when a field is completed.
So far I have the following (please feel free to point out if there's a better way of doing it - I'd like to have it happen when the record shows rather than afterupdate but haven't got around to figuring this out yet!
I used the colour code for the middle one just to try it out - had also tried with vbYellow.
The logic is:
If the current date is greater than the deadline and the date box isn't filled, go red (i.e. overdue)
If the current date is within 7 days of the deadline and the date box isn't filled, go orange (-39662)
If the current date is more than 7 days before the deadline then go white
If the completed date is filled in (i.e. it's been done) then go green
Thanks in advance,
Ruth
Wonder if you can help, I'm trying to get text boxes to conditionally format depending on the dates which are updated automatically when a field is completed.
So far I have the following (please feel free to point out if there's a better way of doing it - I'd like to have it happen when the record shows rather than afterupdate but haven't got around to figuring this out yet!
Code:
Private Sub SUIDateOfAwareness_AfterUpdate()
Me.SUIDeadlineInitialInvestigation.Value = (Me.SUIDateOfAwareness.Value + 1)
Me.SUIDeadlineSHAInformed.Value = (Me.SUIDateOfAwareness.Value + 3)
Me.SUIDeadlineIOReport.Value = (Me.SUIDeadlineInitialInvestigation.Value + 14)
Me.SUIDeadlinePanelDecided.Value = (Me.SUIDateOfAwareness.Value + 14)
Me.SUIDeadlinePanelHearing.Value = (Me.SUIDateOfAwareness.Value + 42)
Me.SUIDeadlineFinalReport.Value = (Me.SUIDeadlinePanelHearing.Value + 14)
Me.SUIDeadlineSHAReport.Value = (Me.SUIDateOfAwareness.Value + 63)
'The code above works fine
If Me.SUIDeadlineInitialInvestigation.Value > Now() And IsNull(Me.SUIDateInitialInvestigation.Value) Then
Me.SUIDateInitialInvestigation.BackColor = vbRed
If (Me.SUIDeadlineInitialInvestigation.Value > Now() - 7 < Now() And IsNull(Me.SUIDateInitialInvestigation)) Then
Me.SUIDateInitialInvestigation.BackColor = -39662
If Not IsNull(Me.SUIDateInitialInvestigation) Then
Me.SUIDateInitialInvestigation.BackColor = vbGreen
Else
Me.SUIDateInitialInvestigation.BackColor = vbWhite
End If
End If
End If
End Sub
I used the colour code for the middle one just to try it out - had also tried with vbYellow.
The logic is:
If the current date is greater than the deadline and the date box isn't filled, go red (i.e. overdue)
If the current date is within 7 days of the deadline and the date box isn't filled, go orange (-39662)
If the current date is more than 7 days before the deadline then go white
If the completed date is filled in (i.e. it's been done) then go green
Thanks in advance,
Ruth