>>I have an inventory type table and when I enter a new part, I want VFP
>>to automatically assign a unique part number to it. I know it can be done,
>>is there an easy way. thanks for the help.
>
>The easy way is to put a function in your Stored Procedures, and make the Default Value of the part number a call to that function.
>
>select the table
>save the record number
>calculate max(part_no) to lnMaxPartNo
>Go oldRecNo
>replace part_no with lnMaxPartNo
>
>That's the fast way. The better way is to save the next part number in another table, and lock that record, get the value, increment it, and unlock the record.
>
>That clear enough, or did I garble it too much?
Along those same lines, I use a function in the stored procedures that looks like this:
Function NextNo
Calculate Max(Part_no) to m
Return m + 1
And then use NextNo() as my default for the field. One BIG CAUTION: the MAC statement will ignore deleted records, but your primary key may not; I use a FOR !DELETED() in my primary key definition for that reason.