Hi Guys,
I am trying to use the DateDiff() in a VBA code which will change text colors base on the result. My issue is I am a little confused as how to I say:
If date is between 30 and 60 days late (so -30 and -60 right?) make it red
If date is 30 days then make it blue but if it is in the future make it black.
Here my test code but it makes all text black so something is off. Can you help me please?
Thank you
I am trying to use the DateDiff() in a VBA code which will change text colors base on the result. My issue is I am a little confused as how to I say:
If date is between 30 and 60 days late (so -30 and -60 right?) make it red
If date is 30 days then make it blue but if it is in the future make it black.
Here my test code but it makes all text black so something is off. Can you help me please?
Code:
Private Sub Command4_Click()
Dim intDate As Integer
Dim date1 As Date
Dim date2 As Date
date1 = Date
date2 = Me.Expires
intDate = DateDiff("d", date1, date2)
If intDate > -60 And intDate < -30 Then
Me.Expires.ForeColor = vbRed
ElseIf intDate > -30 And intDate < 0 Then
Me.Expires.ForeColor = vbBlue
Else
Me.Expires.ForeColor = vbBlack
End If
End Sub
Thank you