Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use on error message on invalid date entry
Message
De
31/08/1997 17:10:38
Glenn Mcburney
Doe(Ni) Information Systems Unit
Belfast, Royaume Uni
 
 
À
22/08/1997 05:01:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00046349
Message ID:
00047888
Vues:
40
>I tried to SET NOTIFY OFF but the "Invalid Date (press space)" message still appears ! Could there be another reason ?
>
>>>How can I use my own error message when an invalid date is entered in a date field ? The system shows this message i.e. "Invalid Date (press space)" at the bottom of the screen. How do I get rid of this and show my own message ?
>>All countries not using English have the same problem but this one could be overcomed like this :
>>SET NOTIFY OFF && Suppress Fox system messages
>>* Write your own or just return 0
>>Error : "Hey you enter a correct date or leave it empty"
>>
>>Cetin

Destine,

This is the way I usually get around this problem.....

1. Don't have a ControlSource on your text box so VFP does not see it as a date field therefore will not fire the date error message.

2. Set the input mask of the field to your desired format, for me it's 99/99/9999.

3. Create a method of your own such as DATEOK and call it when you want to carry out the validation of the user input.

4. In this method attempt to convert your text field to date format using CTOD if VFP detects a date value that is invalid the return value will be a blank date, code such as this also checking for an initial blank entry

if !empty(strtran(This.Value,'/')) .and. ctod(This.Value)={ / / }
lReturnVal=.f.
endif

5. The obvious drawback with this solution is the need to manually place the validated date into the table, again using CTOD eg.REPLACE table.field WITH CTOD(ThisForm.....) and also having relevant code in the Refresh of the field eg. This.Value = DTOC(&lDateField) - I think here you need to make the variable equal to the source path use '&' to do the business.

HTH
I think I have covered everything, if not let me know,
Also sorry for the delayed reply - I've been away.
Glenn
DOE(NI), Belfast
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform