Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate date in a save method
Message
 
 
To
12/04/2007 10:51:16
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01214399
Message ID:
01214991
Views:
23
Yes, tens of reasons, but why you don't want to assign {} to the value to have VFP native validation or use the class I pointed you to, since I know it works (though you may need to change ErrorMsg to messagebox)?

>To solve the problem I defined the following local variables
>
>Thisform.txtTransDate.Value is the date entered by the user.
>
>
>ldDate		= Thisform.txtTransDate.Value
>ldDateType	= VARTYPE(ldDate)
>ldDate		= IIF(ldDateType = "D" , DTOC(ldDate) , ldDate)
>lnMonth 	= MONTH(CTOD(ldDate))
>lnDay 		= DAY(CTOD(ldDate))
>lnYear 		= VAL(IIF(EMPTY(ALLTRIM(RIGHT(ldDate,4))),'0',RIGHT(ldDate,4)))
>lnLenYear	= IIF(EMPTY(lnYear),0,LEN(ALLTRIM(STR(lnYear))))
>
>and do the following test
>
>IF lnMonth = 0 OR lnDay = 0 OR lnYear = 0 OR lnLenYear <> 4
>     error processing and message
>ENDIF
>
>
>Is there a reason that the above would not work?
>
>Thanks for all the suggestions
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