Welcome to SPN

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

Sign Up Now!
  1. Guest ji, please consider donating today!
      Become a Supporter    ::   Make a Contribution   
    Monthly Recurring Target: $300 :: Achieved: $95

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
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page