Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    MN US

    Unanswered: Generate Invoice Number

    Hi all,
    Need a push in the right direction. I am generating invoice numbers using DMax. Adding 1 to the last invoice number. Very straightforward.
    The problem I'm having is that I can't seem to come up with a way to completely control that process.
    My thought was to do this on a "New Record" button:

    Me.AllowAdditions = True
    generate number blah blah
    Me.AllowAdditions = False

    So a user can't add a new record without going through the number generation. Probably missing the obvious but I'm tired and throwing in the towel. Appreciate a push in the right direction.


  2. #2
    Join Date
    Apr 2002

    The best way to control or force the entry of the code number, in this case "Invoice Number", unic i suppose, is to generate them in an afterupdate event of a necessary control and the first to be updated, because the invoice number should be the first thing to appear and not the last. For example [Client Number] AfterUpdate or [Supplier Number] AfterUpdate.

    Don't make the user to click a button to generate the number, use the existing procedures of the controls instead, or other procedures, like the OnCurrent. The users must only input information in the DB and not be worry of a problems of this nature.

    You could use the code in the first control of the tab sequence, so when the user update it the invoice number automaticaly appear.

    The type of code i prefer to number the invoices, orders, etc... Is the Date in number format, like this:

    10/01/05 - day/month/year

    the invoices numbers for this date should be: IN.100105.1 ; IN.100105.2 ; IN.100105.3 ....

    to do this you only have to use the dcount function, to count the number of records that exists with that date, and add 1 to the existing ones.

    to manage the format of the date in this type of number you have to use the Day, Month and Year functions and manipulate them as strings. example:

    Dim D, M, Y as string
    Dim nd, nm, ny as integer



    If nd=1 and nm=1 and ny=1 then
    InvoiceNum= "IN." & 0 & D & 0 & M & 0 & Y & "." & the number of records of the dcount function plus 1

    ElseIf nd=1 and nm=2 and ny=1 then
    InvoiceNum= "IN." & 0 & D & M & 0 & Y & "." & the same thing as before

    etc, etc, etc...

    I prefer this type of number because it say something to you about the date of the document.

  3. #3
    Join Date
    Sep 2003
    MN US

    Thank you!

    That's exactly what I was looking for plus some. Thanks Miguel!
    I never considered using the date that way, but that will fit my needs exactly.

    Thanks again!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts