if not empty(this.value) and empty(ctod(this.value)) && Wrong date>I'm receiving a text field called ExportStartDate from a SQL Server stored procedure. It is defined as a varchar(10), the default value is blank. I'm putting in into a text field on the form and set the Format to D. I put the following code in the Valid hoping to catch if they entered a date incorrectly. My goal is only to have a valid date or an empty value. I thought the CTOD() function would throw an error if the date was invalid, but it simply returns a blank date. While a blank value is valid, it's not valid if they tried to enter a date.
>LOCAL llerror >IF !EMPTY(this.Value) > ON ERROR llError=.t. > mDate=CTOD(this.Value) > ON ERROR DO errsys WITH ERROR(),MESSAGE(1),MESSAGE(),PROGRAM(), LINE(1) > IF llerror=.t. > RETURN .f. > ENDIF >ENDIF >>