Another approach I have used to achieve what I think you are doing is to use cbnewid() for the next PK - loss of some from the sequence is not relevant as there are literally millions available. Then to preserve sequencing of my client numbers/order numbers whatever, I don't generate that until a decision is made to save the record - do this in the beforesave() method. Use some obvious design protocols to 'protect' the data. for example, it is not possible to print an invoice unless it has been initially saved. In other words, don't generate your invoice number until you actually need it rather than in the NEW() method ©2001 graeme thomson |