Results 1 to 3 of 3
  1. #1
    joneca is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    1

    Setting up automatic, unique IDs on forms

    I am developing a request form which lets students submit issues they are having with their accounts. For each request, I want to create a unique ID that starts with the first letter of the request type (e.g. refund, balance) followed by automatic numbering. Is this possible and, if so, what's the best way to do it?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I would recommend using the Autonumber data type in almost every table, always. You will be hard pressed to find a reason not to. With that, you can concatenate text to the Autonumber for display purposes. For instance, after a record is created, code will grab the desired text from a name or whatever and append the text to the front of the number generated by the Autonumber field. You could store this value in the table or simply call the code as needed.

    If the ID's created must be sequential, for example you are going to be audited by the government and they are going to make your life miserable because there is an AL101 and a KA103, but there is not an XX102. Then the Autonumber should be substituted with another option.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Generating custom unique identifier is a common topic. Search forum.

    Autonumber is not guaranteed to increment sequentially nor even to be positive, however, I've never seen it do anything but increment positive sequentially. Autonumbers are not really intended for user viewing, they aren't supposed to have meaning. Their primary purpose is to serve as PK/FK link between records in queries and form/subform (report/subreport) design. Aside from all that, for your situation the autonumber might serve.

    You will want to format the value for display to user, like: [RequestType] & Format([ID], "00000")

    Be aware that gaps can result if user initiates a record but then aborts and does not commit to table. That autonumber is still used up even though it doesn't show in table.
    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. Setting a constant caption for all forms
    By DubCap01 in forum Forms
    Replies: 5
    Last Post: 01-10-2015, 03:39 PM
  2. Replies: 6
    Last Post: 11-23-2013, 10:47 PM
  3. Automatic Update Feature of Forms?
    By mkc80 in forum Access
    Replies: 2
    Last Post: 05-18-2012, 08:10 AM
  4. Replies: 13
    Last Post: 01-27-2011, 11:12 AM
  5. tabular forms - setting values per each record
    By Daytona675 in forum Forms
    Replies: 0
    Last Post: 11-25-2008, 09: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