Results 1 to 15 of 15
  1. #1
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13

    Creating a invoice number field that increases with each new field.

    I have an invoice (form) that I would like to have a field that when you click on new it gives you the next number in sequence. I would like to start it at 4000.



    Thanks,
    Chad.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    OK. Let's say that your Invoice Number is stored in a table name "InvoiceTable" and the field name is "InvoiceNumber".
    Then, on your Form, you could put the following line of code in a command button or after update event (or however/whenever you want it to run):
    Code:
        Me.InvoiceNumber = DMax("InvoiceNumber", "InvoiceTable") + 1
    Note that "Me.InvoiceNumber" is referring to the name of the InvoiceNumber textbox on the Form (which is bound to the InvoiceNumber field in your table).

  3. #3
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    Do you leave the InvoiceNumber as test or number? I am getting a debug error.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Number. You cannot do mathematical functions on Text, at least not without converting them to Number first.

  5. #5
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    I put the code in the date field under "On Dirty" so when the date is entered it should populate that InvoiceNumber field but nothing happens.

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try putting it in a Command Button first, and test that.
    You can also just try returning the calculation to a MsgBox to make sure that the calculation is being done properly.

    Once you are sure it is working properly, then you can try to add it to something else.
    I would use AfterUpdate or BeforeUpdate instead of "On Dirty", and I would also maybe add a check to make sure that it is blank before running that. Otherwise, if you ever change the date, it will overwrite the current Invoice Number with a new one.

  7. #7
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    I don't know if you can help me with this, but I have a form that I enter information in. Once I close the database, and then open it back up, I can't see what I just put in there. but if I go into the tables, I can see it just fine. Am I missing something?

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is the Form set to Data Entry only (so it always open to a blank form)?

  9. #9
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    I have never changed anything. Where would I find that at please.
    Thanks.
    chad.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    It is a form property setting. Look at the Properties Sheet, Data tab.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    Data Entry is set to "No".

  12. #12
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Once I close the database, and then open it back up, I can't see what I just put in there. but if I go into the tables, I can see it just fine. Am I missing something?
    Can you be more explicit in what you see when you go back in to the Form?
    Does it show you a record count at the bottom and allow you to bring up other records?
    Is it just certain fields that are blank, or every field?
    Is your Form a Bound Form?

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Gadgets is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Posts
    13
    I actually took the master copy and opened it, it was working as it should. So i deleted the one on the server and re-split the DB and it works now.

    Now back to the Auto number thing, Is it possible to take the record id and jump it to 40000?

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Do you mean an Autonumber type field? Review http://www.access.mvps.org/access/tables/tbl0005.htm

    If you mean to generate a custom unique identifier - can be any value you want. Common topic. Start with https://www.accessforums.net/databas...try-21975.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-14-2015, 09:01 AM
  2. Combobox subform filter: text field vs. number field
    By Alhassani in forum Programming
    Replies: 2
    Last Post: 07-08-2014, 10:04 AM
  3. Replies: 2
    Last Post: 06-01-2013, 07:00 AM
  4. Invoice Field
    By billgyrotech in forum Reports
    Replies: 8
    Last Post: 04-15-2013, 11:44 AM
  5. Replies: 6
    Last Post: 12-16-2012, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums