Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From/To Dates 1

Status
Not open for further replies.

mommom

Technical User
Nov 14, 2003
208
US
Is there a way that I can:

1. Set a function that a person cannot put in a wrong date in the TO DATE. For example: FROM DATE 1/29/2007 TO DATE 1/30/2006. Want to not allow that to happen.

2. Do not want in TO DATE to go over 365 days from the FROM DATE.
 
Private Sub EndDate_BeforeUpdate(Cancel As Integer)

If DateValue(Me.EndDate.Value) < DateValue(Me.StartDate) Then
Cancel = True
MsgBox "End date cannot be before start date!", vbCritical, ""
End If

if me.enddate > dateadd("yyyy",1,me.StartDate) then
Cancel = True
MsgBox "End date cannot 1 Year after Start date!", vbCritical, ""

end if

End Sub
 
Thank you pwise - works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top