Results 1 to 6 of 6
  1. #1
    redekopp is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    How to create a membership ID field - unique and always increasing by 1

    Good morning, I am still pretty new with more complex things and was hoping someone could help me out. Basically I have a member form and anytime we enter a member obviously there is the primary key which is an auto number ID, but I would also like a membership ID field that is short text such as "MEM-0001" and then always progresses by 1 each time we create a new member. So "MEM-0002", "MEM-0003" etc. How do I go about doing this while ensuring the membership ID is always unique? It will be a field on the form and a short text in the table called MembershipID

    Thank you!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    What exactly is the purpose of "MEM-"?

    For display purposes you could use

    membershipId = "MEM-" & format (ID,"0000")

  3. #3
    redekopp is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Clients request, they would use it for documentation and lookup I suppose. they want MEM as the prefix. Is it loads easier to just drop the prefix?
    They also have another field which is the same thing, a file number that they wanted to use the Prefix S25M-****

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    These request are always historical - It's just a display thing.
    Orange has given you the answer you need. Keep it as a number and just add the pretties on afterwards, and save yourself a whole heap of pain.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    redekopp is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Quote Originally Posted by Minty View Post
    These request are always historical - It's just a display thing.
    Orange has given you the answer you need. Keep it as a number and just add the pretties on afterwards, and save yourself a whole heap of pain.
    So how do I make the number field always unique for each record and always incrementing and using 4 digits? I do not want to use it as a primary key, either.

    Thank you for your responses!

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Use the ID (autonumber as your Primary Key)
    Use the "MEM-" & format (ID,"0000") for the user display

    You can use similar technique with your other table(S25M-****).

    Note: With autonumber you cannot guarantee sequential values. A value will be dropped if user aborts a process with new autonumber.

    See this on Autonumbers

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

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2018, 07:11 PM
  2. Replies: 11
    Last Post: 08-16-2015, 06:48 AM
  3. Create a Field to Calculate Unique/Distinct Count
    By MikeNewAccessUser in forum Queries
    Replies: 3
    Last Post: 03-06-2015, 08:39 AM
  4. Replies: 3
    Last Post: 07-25-2013, 07:20 AM
  5. Replies: 8
    Last Post: 05-08-2013, 10:48 PM

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