The code I posted - and I may have misineterpreted - will detect those records
where the value in Datefield is either in the past or in the next 90 days.
Records where Datefield is after 90 days from today will return "false".
I cannot see your form, nor do I know exactly what you used in your
expression.
To make a message box pop up and appear, you'll need to use the MsgBox()
function in some appropriate form event. I don't know what event that would be
since I don't know how your database is set up - perhaps the Current event
which fires when you move to a record. The code might be
Private Sub Form_Current()
If DateAdd("d", 90, Date()) < Me![Datefield] Then
MsgBox "The date is within the next 90 days or in the past", vbOKOnly
Else
MsgBox "The date is over 90 days in the future", vbOKOnly
End If
End Sub
Thanks John,
My version is 2003 and i have tried your code I have tried using your code
in the design view of the subform but it does not change color when i type in
a date like january 1 2007 which is way beyond the 90 day time frame. Also,
how would i get a message box to appear on enter if condition is true?
John W. Vinson said:
I would like to have the text within a date field turn red and a message box
appear if the date entered is greater 90 days from current date. Can this be
done?
Pretty easily, in A2000 or later.
Select the textbox; on the menu choose Format... Conditional Formatting. Use
an Expression like
DateAdd("d", 90, Date()) < [datefield]
and set the format of the textbox appropriately. You can have a second textbox
and set its visiblity in the same way.
John W. Vinson [MVP]
John W. Vinson [MVP]