Results 1 to 2 of 2
  1. #1
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31

    How to generate a alphanumeric invoice code and insert it into a new field/record?

    Hi!

    I have a table with invoice codes and invoice dates and I would like to build a report with a button. This button would get the highest value in the invoice codes field and add 1 to a brand new invoice and insert this new number into a new record.



    I have managed to get the maximum value using this =DMáx("[CustomerInvNumber]";"tblInvoiceNumber"). In this case it would be I-ABC0024. After that I want to add 1 and insert the new code into the field (CustomerInvNumber) of a new record.

    As you all probably have noticed I am an Access newbie, so I am not sure how to insert values into a new field/record.

    Also, if at all possible, I would like to get some hints on good practices for invoice number generation. What would be a better option, since I-ABC will always be the same for the same customer, maybe it best thing would be to just get this first part of the code, split the previous code in two so I could add 1 and then join it again with I-ABC.

    I would also like to keep the zeroes before the number, that is, I want I-ABC00XX.

    The DB is this: GENERATE ALFANUMERIC INVOICE CODE.accdb

    Thanks in advance!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Generating custom unique identifier is a common topic. Review https://www.accessforums.net/showthread.php?t=23329

    Do you want the sequence to be repeated for each customer? Do you want to avoid gaps in this sequence?

    Easiest approach is to just use autonumber field to generate a unique ID regardless of customer. The text part can be concatenated to number formatted with leading zeros for display purposes.

    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: 5
    Last Post: 05-29-2018, 04:50 AM
  2. Replies: 1
    Last Post: 05-23-2018, 09:35 AM
  3. Replies: 6
    Last Post: 07-01-2015, 10:56 AM
  4. Replies: 6
    Last Post: 05-05-2013, 02:12 PM
  5. Sorting by alphanumeric field
    By RonL in forum Access
    Replies: 1
    Last Post: 10-20-2012, 05:06 PM

Tags for this Thread

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