short date/time check routine

DK8

Registered User.
Local time
Today, 04:07
Joined
Apr 19, 2007
Messages
72
I need to write a routine to check if a date a user enters in a textbox on a form is a valid short date format or not. We only want to allow short dates and not any other types. The form currently takes any date string entered by a user and converts it to long date/time format with the current system date and time. Last week, we got an error message saying the conversion from datetime data type to smalldatetime data type resulted in a smalldatetime overflow. Can anyone provide me with some direction on this or provide some sample code? I would greatly appreciate any help that anyone can provide me with! Thank you.
 
modify the Input Mask for the text box instead: '#0/#0/00##' will only allow up to two numbers(leading zeroes not mandatory) followed by the slash, up to two numbers, slash, up to four numbers. To make the numbers mandatory, use '00/00/0000'
 
Thank you very much :)
 
Additional question:

I want to test for the valid short date range of January 1, 1900 to June 6, 2079. Don't I need to write a seperate function for that, or because I specified short date and the input mask, will VBA work that out automatically? I hope my question makes sense to you, if not please let me know. Thanks again,
 
establish a validation rule for the field and that will restrict the data entry
 

Users who are viewing this thread

Back
Top Bottom