In order to become a unique invoicenumber for each invoice, i use a attached table with a counterfield into which i keep the next invoicenumber to use each time a new invoice has to be printed
In my application, the user select all orders in a multiselectbox for which a invoicereport has to be print, and after that a button is clicked to begin the printing of the invoices.
For each invoice, the invoicenumber in the counterfield of the attached table is retrieved and filled in in the invoicenumber textbox of the invoice. Meanwhile 1 is added to the value of the counterfield,what wil be the invoicenumber for the next invoice to be printed. AFter the printing of the invoice is done, the invoicenumber is saved in the orderstable.
All works well as long as no problem occures during printing. If for some reason the printing of the invoice fails, the number of the invoice is lost what has for consequences that a gap occures in the numbering of the invoices, what is not allowed. I can of course easely change the number in the table to regain the lost number, but the users of my program of course aren't allowed to get directly to the table with the counterfield and so they are not in the possiblilty to correct the number.
How and where should i generate the invoicenumber, keeping the possibilty to print a serie of invoices after selecting the appropriate orders,so that any malfunction of the printing of the report don't give me the described difficulty?.
.