>>>>Michel reading quickly maybe I'm also missing but after "use keylist in 0" you don't select keylist so locating in current (which is most likely EOF).
>
>I found the problem. When it runs the "getkey" code, that changes the current work area to the one for "keylist". When it's done running it, it doesn't put it back in the right work area.
>
>If I do append blank, select clients, append blank, it works. I still don't understand why it would append on top of the old record, though.
>
>Thanks,
So Michel,
To prevent it I suggest open keylist on entry and keep it open. Never select it but do a seek+replace.
proc getkey
parameter lcKeyName
local lnKeyNum
if seek(alltrim(lcKeyName),"keylist","keyindex")
replace KeyList.KeyNum with KeyList.KeyNum + 1
lnKeyNum = KeyList.KeyNum
else
lnKeyNum = 0
endif
return lnKeyNum
Cetin