Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catching invalid date in text field?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01398647
Message ID:
01398649
Views:
64
This message has been marked as a message which has helped to the initial question of the thread.
Simply check for
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 
>
>
>Anyone have an idea how I should approach the validation of the data?
>
>Thanks in advance
>
>Kirk
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform