[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Validate Date field

Posted on 2011-04-24
Medium Priority
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!
Question by:stathisx
LVL 31

Expert Comment

by:Helen Feddema
ID: 35457280
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
   'Your error message
End If

Open in new window

LVL 44

Expert Comment

ID: 35457654
Post the code from the function in which you are having difficulty.
LVL 44

Expert Comment

ID: 35457655
Make that Sub/Function
LVL 23

Accepted Solution

OP_Zaharin earned 1000 total points
ID: 35457951
hi stathisx,
- if you plan to customized most of the errors that might hit on your forms, then you might want to look into the following article. a "The value you entered isn't valid for this field" is not the only error related to date. therefore you need to capture the error number, then specify a customized error for that error number, be it value isn't valid, invalid date format, and so on.


Author Comment

ID: 35458863
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!

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question