Garrett,
>Now that I think about it, it might be better to set lnKeyNum to .NULL., rather than 0: it's a better out-of-bounds indicator.
I prefer to make the routine smart enough to insert a record with 0 as the starting value if it doesn't find the requested table/key sequence name. This way I don't have to remember to run some other program to create those rows. I return .null. if I can't get the rlock()