Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Remind me how, please?
Message
De
27/10/2008 13:49:27
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
27/10/2008 11:49:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01357393
Message ID:
01357439
Vues:
17
>Got a date range, and if the Beginning Date is empty, but the user puts a something in the End Date, I need to display an error message and put the focus back in the Beginning date.
>
>So, someone please remind me how to do that?
>
>Thanks

SetFocus() method might work. But personally, I prefer a different approach: Postpone all validation. Only when the data is saved (or when the user presses an "OK" button to fire some other action, such as printing a report), should you run some code that does all the required checks. Just tell the user what is missing, and let the user complete the missing information, something like this:
do case
case empty(ldDate1)
  ErrorMessage('You need a "from" date.')
  return
case empty(ldDate2)
  ErrorMessage('You need a "to" date.')
  return
case ldDate1 > ldDate2
  ErrorMessage("The second date must be equal to, or after, the first date.")
  return
endcase

* Processing continues here
I am assuming a UDF called ErrorMessage().

The advantages of this approach are several. For one, the user can input data in any order. Two, programming the entire validation is fairly straightforward, and you can easily introduce conditions that span more than one field (such as the last CASE in my example).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform