Results 1 to 6 of 6
  1. #1
    CJ508 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    3

    Random number generators with no repeats

    I currently have 6 fields in my table that each generate a random number between 1-26 when a new record is created. The issue is that some of these numbers are duplicated whereas I need them all to be unique. Is there a simple way around this?



    I have the following code in each of the 'Default Value' field properties.

    (24-1)*Rnd()+1

    Thanks in advance for any help offered!

    CJ

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you using the Randomize() function?

  3. #3
    CJ508 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    3
    I'm using the Rnd() function in each Default Value property of each of my 6 fields, as follows:

    (24-1)*Rnd()+1

    Problem is I get repetitions and I need them all to be different

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Even random numbers will duplicate rendomly. If you are doing this in the field definition of the table, you are asking too much from the table. Keeping it unique will have to be your responsibility and better accomplished in a form.

  5. #5
    CJ508 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    3
    I understand that I am asking too much of the table, so do you know of a way I can get round this? Thanks for your responses so far

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm sorry but I do not.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-10-2009, 05:42 AM
  2. Random numbers
    By Gator777 in forum Access
    Replies: 3
    Last Post: 08-12-2009, 10:04 AM
  3. Sum Of Positive Number and Negative Number
    By maysamab in forum Reports
    Replies: 1
    Last Post: 10-20-2008, 04:06 PM
  4. random record
    By wasim_sono in forum Programming
    Replies: 1
    Last Post: 02-06-2008, 02:42 PM
  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