date txtbox could not contain date less than today date

Falcon88

Registered User.
Local time
Today, 21:38
Joined
Nov 4, 2014
Messages
309
hiiiii all

i have a continous sub form in (ExpiryDate) field ,beforeupdate event i try to get msg, when user enters date before this today date , but it coud not work:
i try this code
Code:
Private Sub ExpiryDate_BeforeUpdate(Cancel As Integer)
If Me.ExpiryDate < Date Then
 If MsgBox("please enter a date greater than today, are you sure ? " & vbCrLf & _
      Date, vbInformation + vbMsgBoxRtlReading + vbMsgBoxRight + vbYesNo, " be sure ") = vbYes Then
     Cancel = False
     Else
     Cancel = True
     Me!ExpiryDate.Undo

     End If

End If
End Sub

what is the wrong in that code ?
 
Try it in the afterupdate event and use me.expirydate.oldvalue
or overrule the user by

if expirydate<Date then
expirydate = date
msg ("warning to user")
end if
 

Users who are viewing this thread

Back
Top Bottom