We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Validate Date field

stathisx
stathisx asked
on
Medium Priority
664 Views
Last Modified: 2013-11-28
Hello experts ,
i have a problem with date validation.What i want to do is to validate the date field in my form and disable access error messages at the same time.In face i have implemeneted the validation rule for the date field and i have configured input mask and validation text. Although if i enter a wrong date in the format dd/mm/yyyy , for example :12/13/2011 (which is wrong) i get :
"The value you entered isn't valid for this field" .How can i prevent this from happening and display only my custom text entered in the validation text property ?
(I forgot to mention that i have user error handling for this and it didn't work.Is there any other way to achieve this ?)

Waiting for your replies!
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
Try this code on the BeforeUpdate event to check that a valid date has been entered into a control.  There may not be a need for a validation rule.

In my experience, it is best to not have an input mask for dates, but just use the Format property to display the date in the desired format, no matter how it was entered.


If IsDate(Me![txtFromDate].Value) = True Then
   Cancel = False
Else
   'Your error message
End If

Open in new window

Commented:
Post the code from the function in which you are having difficulty.

Commented:
Make that Sub/Function
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
in the form onerror event i trapped the error codes (2113 and 2116) and changed the response argument to acdataerrcontinue and it worked .
thank you all for the replies!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.