Craig,
Duh! Oh, PK means primary key. In my defense, I have a severe head cold. Here goes. Primary key code is as follows:
In calling program:
NewKey=GetNewPrimary()
replace theprimarykey with NewKey in thisTable
**********************
Procedure GetNewPrimary
local newTnumber,nowdbf
nowdbf=alias()
newTnumber=0
use misc in 0 again alias ms
use theTable again in 0 alias NewKeyTable order primarykey
sele ms
set reprocess to -1
set deleted off
local ix
newTnumber=ms.mytrans
sele NewKeyTable
for ix=1 to 100000
seek newTnumber
if found()
newTNumber=newTnumber+1
else
exit
endif
next
sele ms
if flock()
repl ms.mytrans with newTnumber+1
unlock in ms
endif
set deleted on
use in ms
use in NewKeyTable
if !empty(nowdbf)
sele (nowdbf)
endif
return newTnumber
While this may not be the most elegant code in the world, I do know that if it fails I will get a primary key violation in short order. I know this because originally I did not have the Set Deleted Off statement and my users generated primary key violations all over the place.
Incidently, how does one format text in this editor?
A problem is a problem only as long as it has a possible solution. Lacking that, it becomes a FACT!