Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary Key with one to many Form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00530359
Message ID:
00530488
Vues:
27
This message has been marked as a message which has helped to the initial question of the thread.
Hi Leroy,

This is a routine I use to generate a sequential numeric key field.


Table NEXTCD.DBF holds the sequences and next key fields and is part of the database:

seqname c20
nextcd I



This routine goes in the "Stored Procedures" area of my database.

FUNCTION NEXTCD(m.passedalias)
* calc and pass back next sequential record code
local m.alias, m.nextcd, m.oldproc, m.oldarea
m.oldarea = select()
if pcount() < 1
m.alias = upper(alias())
else
m.alias = upper(m.passedalias)
endif
m.nextcd = -1
m.oldprocess = set('reprocess')
set reprocess to automatic
if .not. used('nextcd')
use \nnjvfp\data\main!nextcd in 0 again
endif
select nextcd
if seek(m.alias,'nextcd','seqname')
if rlock()
repl nextcd with nextcd + 1
m.nextcd = nextcd.nextcd
unlock
endif
endif
select (m.oldarea)
set reprocess to (m.oldprocess)
return m.nextcd



I place this statement in the default value of the key field of the table:

=nextcd('tablename')


Each time a record is appended to the table a new key is created, whether from a browse window, wizard generated form, append, whatever.

Hopefully this will be helpful to you...

Regards,

Todd
The day you take complete responsibly for yourself, the day you stop making any excuses, thats the day you start to the top. - O.J. Simpson

Great advice from a questionable source...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform