Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto-incrementing a number field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00168371
Message ID:
00168508
Vues:
22
<>

Being new to VFP6, I can't do much with telling you *how* to accomplish my suggestion, but I do have a couple tips:

1. If this is in a multi-user environment, you could easily wind up with two records having the same number. User 1 could press ADD and get *new number+1*, and still be completing the rest of the form while User 2 does the same. Since User 1's new number has not yet been added to the DBF, both have *new number+1.*

2. To avoid this problem, consider adding another table to your project for "next numbers" When a user presses ADD, the number on the form is shown as "NEW" until SAVE is pressed. During the SAVE, the program locks the next number DBF field, gets the value, increments it by 1, writes the new value to the next number DBF, and then applies the number to the User's form and database. This approach prevents two records from having the same number!

HTH,
Phil Thomas
http://phillipdthomas.com

Never let your energy or enthusiasm be dampened by the discouragements that must inevitably come.....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform