Future Date Validation

majid.pervaiz

Registered User.
Local time
Today, 20:45
Joined
Oct 15, 2012
Messages
110
Dear All,

I have the below code on a field that contains a date, I don't want user to enter a future date in the field. But unfortunately, it's not working, not sure the reason.

I tried the same on lost focus event also.

appreciate your advice.

Private Sub BO_App_Date_Exit(Cancel As Integer)
If Me.BO_App_Date > Date Then

MsgBox "you cannot put future date", vbExclamation
Me.BO_App_Date.Value = ""
End If

End Sub
 
Use the before update property

If Me.BO_App_Date > Date Then

MsgBox "you cannot put future date", vbExclamation
Cancel = True
End If
 
no it didn't work... I am really shocked. I did the same thing on another form but I don't know why in specific on this form it's not working
 
well I have use validation rule and validation text for now... God knows why it's not working
 
Did you get an error, and did you remove all the other events on that control to avoid confusion ?
 
Minty bro resolved - actually I overlooked one thing. I had some data existing so what was happening the date let's say is mentioned 01/01/2016 the moment I click on the calendar I was selecting 15/08/2016 and didn't notice the month... offcourse system will not then tell me it's a future date :(

apologies for inconvenience caused.

many thanks
 
I probably would not clear out what the user has entered, so that they can see their mistake.
 

Users who are viewing this thread

Back
Top Bottom