Results 1 to 6 of 6
  1. #1
    Mellen105 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3

    Auto-Increment a New Unique ID

    I am very to new to Access and have some basics down but have been stuck on my current situation for a few hours now. I've been reading several posts about how to create an auto incrementing unique ID for new records on a form and need some help. With my limited knowledge I am going to need help with simple things like what screens and buttons to click on so please bear with me as I get through this.



    I have created a form to add new records to my table. What I want to do is when I create a new record by hitting the "Add New Record" button it will populate my auto incrementing unique ID. My ID will be stored in a field titled "RequestNumber" and looks like this R_2013_001, R_2013_002, R_2013_003, R_2014_001, R_2014_002, R_2014_001, etc. Essentially I have R as a prefix, the year the request was made, and then the auto-incrementing number at the end. The auto-incrementing number should start over at the beginning of each year.

    My situation is pretty similar to this thread. I need a bit more help though as I am a complete beginner to this portion of Access. I need help modifying the code, knowing how and where to put it within Access and the finally how to properly set up my "Add New Record" button.

    I will be the only one using this database so I do not need to worry about another user creating records at the same time.

    Key fields in my database:
    Unique ID = "ReqestNumber" - this is the field to be auto-populated
    Date = "DateRequested" - auto-populates with today's date for a new record

    Thanks for the help!




  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I do that - generate unique ID and start over each year. Here is my code http://forums.aspfree.com/microsoft-...ta-403208.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.

  3. #3
    Mellen105 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3
    Thanks for the help, but honestly this is still over my head. I don't even really know where to add this code in through Access or how to configure the "add new record" button properly. Access and VBA are both very new to me.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Do you have any programming knowledge? From any programming language?

    Start learning with:
    http://office.microsoft.com/en-us/ac...010341717.aspx
    http://www.ehow.com/about_6621833_in...ogramming.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.

  5. #5
    Mellen105 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3
    I've done some stuff in Python, but nothing too extensive. Those were pretty simple codes set up to use a series of procedures in the proper order. VBA I have done no coding with. Within Access I have set up databases, forms and simple queries and relationships but nothing too extensive. I have never had to code anything similar to this.

    I'll spend some time reading through those links you sent but any other additional help is greatly appreciated.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Basically, the function code from my example goes in a general module. The other code is shown behind a button on form and that would be the most likely case for you. I have the code split because the function is called from several forms.

    I don't know your db so hard to say what the exact mods will be, certainly table and field names will be different.
    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. Auto increment Letter
    By andy-29 in forum Access
    Replies: 4
    Last Post: 11-08-2012, 05:23 PM
  2. Auto Increment Reset
    By Sibtain in forum Programming
    Replies: 3
    Last Post: 10-25-2012, 01:59 AM
  3. Auto Increment Textbox
    By alyon in forum Access
    Replies: 3
    Last Post: 07-15-2011, 06:38 AM
  4. Replies: 5
    Last Post: 11-12-2010, 12:10 PM
  5. Auto Increment by 1 Letter
    By Cinquefoil22 in forum Database Design
    Replies: 4
    Last Post: 07-02-2010, 10:35 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