+ Reply to Thread
Results 1 to 4 of 4

Thread: Random Auto Number as ID Key

  1. #1
    Registered User
    Join Date
    09-10-2010
    Location
    Sanford, FL
    MS-Off Ver
    Excel 2010
    Posts
    39

    Red face Random Auto Number as ID Key

    Is there a way to limit the random ID number for the primary key to a three digit number? I have it set to random and the numbers I get are 10 digits long. I am using Access 2010.
    Last edited by Juli; 08-30-2011 at 09:05 PM. Reason: update to version

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: Random Auto Number as ID Key

    How are you creating the random number now?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    09-10-2010
    Location
    Sanford, FL
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Random Auto Number as ID Key

    Dave,
    I entered the data type as auto number which only gives two choices as Field Size, long interger and replication Id- I choose Long Interger. Under new valuse I choose Random, under indexed I requested no duplicates.
    Julie

  4. #4
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: Random Auto Number as ID Key

    I don't think you want to limit a key to 999 numbers. You assume that you'll never have more than that many records, but databases can and do change often, and when that happens you'll need more work to fix it.

    Can I ask why you want three digit numbers? Keys should be used only for relationships from one table to another. If you want a separate number that can be random and between 0 and 1000, maybe use a different field, filled via vba?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0