Invoice numbers.

  • Thread starter Thread starter Lasse T
  • Start date Start date
L

Lasse T

Hello!!
Let´s se if anyone can help me with this.

I have had some trouble with invoice numbering, I got most of it solved but
today i ran into something I had not thought about.
I don´t know if this is the way to do it but here´s what I did. I made a
table with only one field, invoice number and put that field in the report
(invoice). When I print the report i run an update query that rewrites the
invoice number in the table with one (1) added to it. This works fine and I
was happy until I started to think a little longer down the road. This will
only work when I print one invoice at the time. What should I do when I have
more then one unprintet invoice and want to print them all? I have not tried
yet but I understand that all the invoices will have the same number sins
the query only runs once. It feels like I have to start over with the
invoice numbering but I can not think of another way to do it. I don´t want
to use the autonumbering in the table.

Any ideas would be highly appreciated.

Lasse T
-----------
 
I don´t know if this is the way to do it but here´s what I did. I made a
table with only one field, invoice number and put that field in the report
(invoice). When I print the report i run an update query that rewrites the
invoice number in the table with one (1) added to it.

I'd suggest storing the invoice number *in the Invoice table*. A
Report *is just copying information to paper* - as a rule, you might
have an invoice printed once, printed three or four times, or maybe
not printed at all! The invoice number should not be changed just by
printing it.

I agree with not using an Autonumber, but I'd suggest that you use a
Custom Counter. For instance, you could use a Long Integer field as
the Primary Key of the invoice table; when you're entering the
information that makes up an invoice, you can automatically set that
field to one more than the largest existing invoice number in the
Form's BeforeInsert event with some simple code like:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtInvoiceNo = DMax("InvoiceNo", "Invoices") + 1
End Sub
 
John Vinson said:
I'd suggest storing the invoice number *in the Invoice table*. A
Report *is just copying information to paper* - as a rule, you might
have an invoice printed once, printed three or four times, or maybe
not printed at all! The invoice number should not be changed just by
printing it.

I agree with not using an Autonumber, but I'd suggest that you use a
Custom Counter. For instance, you could use a Long Integer field as
the Primary Key of the invoice table; when you're entering the
information that makes up an invoice, you can automatically set that
field to one more than the largest existing invoice number in the
Form's BeforeInsert event with some simple code like:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtInvoiceNo = DMax("InvoiceNo", "Invoices") + 1
End Sub

Thank you for the code. It works, but it does not fully solve my problem.
All the info I need to create an invoice are already stored in the order
table exept for invoice date and invoice number. I have a yes/no field in
the order table that tells me if an invoice are created from the order. When
it´s time to create invoices from the days orders I open a continous form
that shows allt the orders that has not been created invoices from. In that
form I want to set date and invoice number and print the invoices. It seems
to me that I need to run this code in some kind of loop to create invoice
numbers in all the post of the continous form. My knowledge in VBA are way
to small to do this. Any help would be highly appreciated.

Lasse T
---------------
 
Thank you for the code. It works, but it does not fully solve my problem.
All the info I need to create an invoice are already stored in the order
table exept for invoice date and invoice number. I have a yes/no field in
the order table that tells me if an invoice are created from the order. When
it´s time to create invoices from the days orders I open a continous form
that shows allt the orders that has not been created invoices from. In that
form I want to set date and invoice number and print the invoices. It seems
to me that I need to run this code in some kind of loop to create invoice
numbers in all the post of the continous form. My knowledge in VBA are way
to small to do this. Any help would be highly appreciated.

Lasse T
---------------

If you want to associate an invoice number with an order - *associate
the invoice number with the order*. Your Order table should have an
InvoiceNo field, NULL if there is no invoice (yet) for this order; you
can adapt the code to update the table or store that invoice number.

Generating the invoice number in a loop will NOT reliably allow you to
ensure that invoice numbers are unique, or that they will remain
associated with the same order.
 
Back
Top