Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid date problem
Message
From
14/05/2004 14:52:43
 
 
To
13/05/2004 17:43:41
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00903862
Message ID:
00904173
Views:
25
This message has been marked as the solution to the initial question of the thread.
Christian-

>We have to Set Century ON. When we enter a date as 01/01/1111 in a text box (any year before 1601), we get an "Invalid date" error that we can't trap. But more ennoying, when we tab to the next field, the app simply quits (God knows why). We can't intercept and check the value in any event: we tried rangehigh(), rangelow(), valid(), lostfocus(). We also tried to set Strictdate to 0 and Strictdateentry to 0 with no change.
>
>Checking the .Value or .Text in the InteractiveChange or Keypress is not suitable as the users hasn't finished typing. I'm interested to know how VFP programmers manage this behavior a date textbox control.

I found the same problem you have. Here was what I found. When using short date format, and when my textbox is bound to a form property, the _form's_ Error() fires instead of the textbox's. Here is the code from a baseform class error method. I hope it helps.
LPARAMETERS nError, cMethod, nLine
IF nError = 2034 && Date/datetime evaluated to an invalid value.
  MESSAGEBOX('Please enter a valid date',0+16,"Error in date entry",5000)
  IF TYPE('this.activecontrol.value')="D"
    THIS.ACTIVECONTROL.VALUE = {}
  ELSE
    *!* It would be nice if the textbox could trap this error instead of the form.
    *!* However, if a control is bound to a form property, the error is trapped here.
    KEYBOARD '{CTRL-Z}'
    DOEVENTS FORCE
  ENDIF
ELSE
  MESSAGEBOX(MESSAGE(),16)
  ASSERT .F.
ENDIF
IF .F.
  RETURN
  RETRY
ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform