Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Basic - Procedure Question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00466388
Message ID:
00466448
Vues:
10
Bob,
Craig's suggestion of using a separate class which handles business rules is excellent. However, if it would mean re-writing your app there are other "1-tier" ways of handling this.

First, you can return from the SAVE button by adding a "Return" or "Return .F." command at the point where you want to exit the SAVE code. I use the "Return .F." construction, so that if I'm calling the Save button code from somewhere else I know if the Save was completed or not.
** Sample SAVE code
if thisform._textfield1=0
   **something wrong
   =Messagebox("Cannot save, data is incomplete")
   return .f.
else
   ***  Remaining SAVE code
   return .t.
endif
Second, there are several ways of handling the problem of fields not filled in. The simplest is to check each of the required fields in your SAVE code. This would have to be changed for every form.

Another way is to add an "llRequire" property to each of your base controls. Then in the SAVE code run through all of the controls on the form (check the "Controls" object in Help) to see which have the property set to TRUE. If they are empty, then you can't save. This is more difficult to set up at first, but makes it simpler to change the form or to do a second or third form with the same controls and the same SAVE code.

HTH
Barbara

>What do people do for standard validation of data. ? how do you make screens react ?
>The valid propertity while it works. is not what I am looking for, (what if the user never gets to that field, and the data, cant be left out.
>
>Onto the question
>if I have a save button, which is suppose to check the data before writing it to the database ?
>like this
>if thisform._textfield1=0
>* something wrong"
>** how to I put control back to the form, with
>
>endif
>then write the data
>
>I tried doing a setfocus() but the save button just goes back and saves it anyway.
>
>I was thinking of putting the isvalid() in seperate class. Anythought ?
>
>Thank you
>Bob lee
Barbara Paltiel, Paltiel Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform