Results 1 to 7 of 7
  1. #1
    DerekAwesome is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    15

    How would I go about automatically generating user-specific ID numbers?

    I'm attempting to create a system for task scheduling, and I essentially want each task to have an ID specific to its user. Basically, I have autonumber generating a 4 digit user ID (ie 0001), and I want each task ID to have this 4-digit ID, as well as an automatically generated ID for the specific task.

    So basically, User 0001's tasks would be ID'd as 00010001, 00010002, and so on, and User 0002's tasks would be 00020001, 00020002.

    So basically I'm asking. Is there a way I can make custom autonumbers with the user ID first and then another 4 digit ID for the task?

    I know it sounds confusing, I'm bad at explaining things.

    Also, if there is a cleaner way to design the database, please let me know. Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Why not just have an Autonumber, that is auto-incrementing, and then a separate field to track the User ID?
    Is there some reason why you want them both combined together in a single field?

  3. #3
    DerekAwesome is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    15
    Basically my methodology is that with user ID embedded, each user could have up to 9999, whereas if task ID is separate there would be a limit of 9999 total tasks for all users. is there a way I could make the autonumber increment separately for each user ID?

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Basically my methodology is that with user ID embedded, each user could have up to 9999, whereas if task ID is separate there would be a limit of 9999 total tasks for all users.
    Why, what is setting this limitation? Why are you limited to 9999?
    is there a way I could make the autonumber increment separately for each user ID?
    Yes and No. Yes, you can do this, no it isn't an autonumber that will be increment automatically.
    If you control all data entry through a Form, you can create VBA code on the Form that will look up the maximum value for a specific user ID, add one to it, and populate your ID field with this value.
    If you are importing data, you will need to run some VBA scripts after to calculate and populate each value.

    So it really depends on how data is being entered.
    By the way, how are you capturing User ID?

  5. #5
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    You could have two auto numbered fields. One for the USERID and another for the TASKID. If you must combine them together you can either use a Calculated field in your table, or just concatenate in your Queries and VBA.

  6. #6
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    ok so to set a few things straight. one cannot have 2 auto number fields in the same table. next - anything with leading zeros cannot be a number field type - it must be a text field type.

    so you must have 2 number fields - lets call them First4 and Second4 then you need a text field ID

    the two number fields serve to generate the ID field

    at some appropriate point in the User Interface process one is going to need to find the Max First4 and then +1 ; do the same thing for Second4; and then for each separately you must count the character length, and then insert the appropriate number of leading 00s while merging them together with a Write into the ID field

  7. #7
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Quote Originally Posted by NTC View Post
    ok so to set a few things straight. one cannot have 2 auto number fields in the same table. next - anything with leading zeros cannot be a number field type - it must be a text field type.

    so you must have 2 number fields - lets call them First4 and Second4 then you need a text field ID

    the two number fields serve to generate the ID field

    at some appropriate point in the User Interface process one is going to need to find the Max First4 and then +1 ; do the same thing for Second4; and then for each separately you must count the character length, and then insert the appropriate number of leading 00s while merging them together with a Write into the ID field
    Indeed, I hope he is keeping his tasks in separate table.

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

Similar Threads

  1. Generating Range of numbers
    By frikkie in forum Access
    Replies: 1
    Last Post: 07-27-2013, 10:46 AM
  2. Generating sequential numbers automatically
    By Malcolm41 in forum Access
    Replies: 2
    Last Post: 07-15-2012, 08:20 PM
  3. Access generating random numbers
    By dama in forum Forms
    Replies: 1
    Last Post: 02-19-2012, 06:36 PM
  4. generating automatic numbers in a database
    By bonbon68 in forum Access
    Replies: 3
    Last Post: 03-16-2011, 10:09 AM
  5. generating random numbers on form
    By anitra in forum Forms
    Replies: 1
    Last Post: 02-14-2006, 10:08 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