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:
00168511
Vues:
21
>Hi ALL!
>
>I would like to have the first field on a form auto-increment with each new recorded added to the forms table. I know of the NEWID() way, but this involves modifing the table. Does any have any suggestions on how I can accomplish this useing just code?
>
>I considered useing the last Record number in the table and incrementing it by 1 each time, but No matter where I place my simple code, it gives errors and\or totally flips out the "add" function to the form.

Hi Dan,

I presume the number your want in first_field is the record count of the table, yes? If so,

In the refresh() method of first_field, include,

.value = RECCOUNT("myfirstfieldtable")

This assumes that you _do not_ link first_field to a control source.

Then in the whatever method you use to add a record (actually this should be in the add AND delete record functions), add the following line,

thisform.first_field.refresh()

that should do it.

regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform