NomoreSpam4Me@hotmail.com wrote:[color=blue]
> Hi there i have a little problem with my invoice.
>
> Here it is:
>
> i have a main menu with buttons, one of my button is "Create new
> invoice", when click on it a form pop up so i can enter my information
> and one of the field (the user cannot change the info in it.) is
> invoice #. Right now, everythime i click on "Create new invoice", the
> invoice # add 1. But my problem is sometime the employee dont fill it
> (for x reason) and shut it down, the nest time they will click on
> "Create new invoice" the invoice # will be 1 more then the last one.
> There will be a blank invoice between them.
>
> Is there a way to get rid of this??
>
> thx a lot.
>[/color]
Is the Invoice number an autonumber field? If so, this is to be
expected. An autonumber is not a good method to use for sequential
numbers. An autonumber is GREAT as a key field to link to other tables.
If you enter anything into the form, the autonumber increments. Even if
you undo your changes, the next time the invoice form is opened, a new
number will be one more than the last time an autonumber was
incremented, whether or not the record was saved. So you can expect
holes in the sequence.
The better thing to do is make the invoice number field in your table a
LongInt number. Simply remove the Autonumber type from the table and
change it to Number, type Long. And make it the primary key.
Now you need to determine when you want the record to create new invoice
number. If ONLY ONE person is updating/creating invoices, you can do
something like
If Me.NewRecord then
Me.InvoiceNumber = Dmax("InvoiceNumber","InvoiceTable")
Endif
anytime you want. If you are going to have multiple people entering
invoice numbers at the same time, you might want to do that in the
BeforeUpdate event of the form...IOW, just prior to saving the record.