Assuming this is a bound form, use the BeforeUpdate event procedure of the
*form* to verify that the end date is after the start date. That's always
the best approach for comparing 2 dates, becuase you don't know which order
the user will enter them.
Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me.ProjEnd < Me.ProjStart Then
Cancel = True
MsgBox "Cannot end before it starts."
End If
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"deb" <(E-Mail Removed)> wrote in message
news:AD0E7A25-7891-4228-821A-(E-Mail Removed)...
>
> I am using Allan Browne's calendar and it works great!!
> I have a form with ProjStart and ProjEnd, both are date fields using the
> calendar.
>
> I need to make sure the ProjEnd is not before ProjStart.
> I tried...
> Private Sub ProjStart_AfterUpdate()
> If Me.ProjStart> Me.ProjEnd Then
> MsgBox "ProjEnd cannot be before ProjStart"
> Me.ProjStart.Undo
> End If
> End Sub
> But it only works if the date is typed in, and not when using the calendar
> control.
>
> The calendar is triggered by the OnClick event using,
> =CalendarFor([ProjStart],"Set Project Start date")
>
> Please help,
>
> --
> deb