Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Increase a No automatically when creating a new invoice

Discussion in 'Information Technology' started by danh, Jul 28, 2006.

  1. danh

    danh
    Expand Collapse
    Guest

    When I create a new invoice I would like the new no. to come on my form
    automatically. It reads the last InvNo and adds 1 to it and displays it on
    the screen. Can somebody help me do this?
    Thanks
    Dan
     
  2. Loading...

    Similar Threads Forum Date
    Increase Potassium, Cut Salt to Reduce Stroke Risk Health & Nutrition Apr 5, 2013
    Islam Number of Moques increase by 74% in USA after 2000! Interfaith Dialogues Mar 2, 2012
    India Rate of Aborted Female Fetuses Increases in India Breaking News Apr 2, 2011
    Mobile Phone Use Not Related To Increased Brain Cancer Risk Information Technology Feb 28, 2011
    Controversial INTERPOL issues global alert for increased terror threat if Koran burning in US goes ahead as planne Hard Talk Sep 9, 2010

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Best to do this in the BeforeUpdate event of the form. That's the last
    possible moment you can assign the number before the record is saved. This
    timing reduces the chance that 2 users who are both entering data will be
    assigned the same number.

    Set the BeforeUpdate property of the form (not that of a control) to:
    [Event Procedure]

    Click the Build button (...) beside this.
    Access opens the code window.

    Between the "Private Sub..." and "End Sub" lines, enter:
    Me.[InvoiceID] = Nz(DMax("InvoiceID", "tblInvoice"), 0) + 1

    Replace InvoiceID with the name of your number field, and tblInvoice with
    the name of your table.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "danh" <danh@discussions.microsoft.com> wrote in message
    news:764EB741-DAA0-427E-ACE2-04F2C0367C7B@microsoft.com...
    > When I create a new invoice I would like the new no. to come on my form
    > automatically. It reads the last InvNo and adds 1 to it and displays it
    > on
    > the screen. Can somebody help me do this?
    > Thanks
    > Dan
     
  4. ads

    ads
    Expand Collapse
    Guest

    The autonumber field in Access would be your best bet..

    you can access this through the design of your table , you would have
    to change your invoice no field
    then you can reference that field on your form

    Cheers

    ads
     
  5. danh

    danh
    Expand Collapse
    Guest

    Thanks so much Allen. I will try it.

    "Allen Browne" wrote:

    > Best to do this in the BeforeUpdate event of the form. That's the last
    > possible moment you can assign the number before the record is saved. This
    > timing reduces the chance that 2 users who are both entering data will be
    > assigned the same number.
    >
    > Set the BeforeUpdate property of the form (not that of a control) to:
    > [Event Procedure]
    >
    > Click the Build button (...) beside this.
    > Access opens the code window.
    >
    > Between the "Private Sub..." and "End Sub" lines, enter:
    > Me.[InvoiceID] = Nz(DMax("InvoiceID", "tblInvoice"), 0) + 1
    >
    > Replace InvoiceID with the name of your number field, and tblInvoice with
    > the name of your table.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "danh" <danh@discussions.microsoft.com> wrote in message
    > news:764EB741-DAA0-427E-ACE2-04F2C0367C7B@microsoft.com...
    > > When I create a new invoice I would like the new no. to come on my form
    > > automatically. It reads the last InvNo and adds 1 to it and displays it
    > > on
    > > the screen. Can somebody help me do this?
    > > Thanks
    > > Dan

    >
    >
    >
     
  6. danh

    danh
    Expand Collapse
    Guest

    Thanks so much ads but it I didn't want to use the Autonumber as I want the
    invNo to follow each other.

    "ads" wrote:

    > The autonumber field in Access would be your best bet..
    >
    > you can access this through the design of your table , you would have
    > to change your invoice no field
    > then you can reference that field on your form
    >
    > Cheers
    >
    > ads
    >
    >
     

Share This Page