Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Here we go w/the invalid date value again
Message
From
13/03/2002 06:24:35
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00631821
Message ID:
00631953
Views:
27
>OK We've been down this road before and now it's bitten us in the arse again, so here goes:
>
>SET("DATE") is SHORT for our application because we specifically do not want to force a date format within our application. According to VFP7's docs this causes any date prior to 01/01/1601 to be an invalid date value and causes an error. We have a need to trap this error for the sake of anticipating a typo on the part of the user (God forbid, right? :) ).
>
>After unsuccessfully trying to trap this error in our form class' Error event, we've gone to using a global error handler to trap the date problem. We're specifically trying to trap error code 2034 (invalid date/datetime value). In the trap, we're throwing up a MESSAGEBOX and ignoring the error with the expectation that execution just continues and the user can attempt to re-enter the date.
>
>What happens is that if we enter a sample date of 01/01/1200 in a form, the messagebox gets fired as expected. However, execution then continues past the READ EVENTS line in our main prog. Then, our form gets unloaded and fires its Unload code and the application terminates. Is there something in the handler we need to add so that this doesn't occur?
>
>We're kind of at our wits end on this one, so any assistance would be greatly appreciated. We can't change our SET DATE setting and we definitely can't have a date typo result in an abnormal termination of the app.
>
>HELP!
>
>Laterness,
>Jon

Jon,
I'd set date format to one of DMY,YMD,MDY asking users. Anyway you could control it in lostfocus of date fields. ie :
if !empty(this.value) and year(this.value)<1601
 messagebox('Wrong date')
 nodefault
endif
Or you might provide your users a calendar control for more flexibility.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform