Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    scottdg is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    31
    I don't need to use up all 70 numbers first. It is okay if I run it and get:



    2, 23, 45, 67, 14, 7, 70, 55, 13, 37
    then the next time (or two or three times down the line)
    4, 65, 17, 63, 52, 23, 29, 41, 62, 19

    I will review what you sent and see if I can get any ideas.

    Thanks,
    Scott

  2. #17
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Ok. It still isn't clear exactly what you want. You said unique - no repeats - so 1 or 2 repeats seems acceptable??

    My article on selecting N random numbers should be a starting point to give what you need. Just use Top 10 -- not percent.

  3. #18
    scottdg is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    31
    sorry - repost

  4. #19
    scottdg is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    31
    When I say repeats I mean of the 10 number selected each can only be selected once.

    2, 23, 45, 67, 14, 7, 70, 55, 13, 37 is acceptable
    2, 23, 45, 67, 14, 7, 23, 55, 13, 37 is not acceptable

  5. #20
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    OK, i read your previous example incorrectly. I thought both lines were acceptable --ok so you have it working.
    Good stuff.

  6. #21
    scottdg is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    31
    No - still producing the unacceptable results (7 out of last ten times). I was not able to use any of the examples to get it working properly.

    I am better at reading code at this point then I am writing it so it could be me.

  7. #22
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Did you copy and paste the function and test routine I provided?

    You can adjust the code to work with different ranges.

    Can you post the code you are using that is giving you problems?

  8. #23
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I am attaching a sample database.
    I tried to mock-up your situation by setting up table with 2 fields recordid and xtrafield.
    RecordId simulates your recordid (record identifier) and
    xtrafield is where I record a random number.

    I created the table, then populated it with routine MakeRecords in module1.
    I then ran routine dgScottStuff in module1. This routine populates or repopulates the value in xtrafield with a random number.

    Query, QueryToGetRandomRecords with sql

    Code:
    SELECT SubQuery.recordID
    FROM (
        SELECT TOP 10 tblSampleRecords.RecordID
            ,tblSampleRecords.xtrafield
        FROM tblSampleRecords
        GROUP BY tblSampleRecords.RecordID
            ,tblSampleRecords.xtrafield
        ORDER BY tblSampleRecords.xtrafield
        ) AS SubQuery
    ORDER BY SubQuery.recordID;
    Selects 10 random records from the table.

    You can repopulate the xtrafield by running dgScottStuff at any time. This will assign different(very high probability) random numbers to xtrafield, and the select top 10 would result in a different set of records (with some probability of repeats).

    Good luck
    Attached Files Attached Files

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Random Number
    By MTSPEER in forum Queries
    Replies: 3
    Last Post: 04-14-2015, 11:37 AM
  2. random value generator between 2 dates
    By cbrxxrider in forum Queries
    Replies: 7
    Last Post: 03-06-2014, 07:57 PM
  3. Number generator without Autonumber?
    By Megood in forum Programming
    Replies: 7
    Last Post: 07-19-2012, 08:02 PM
  4. No-So-Random Number
    By oleBucky in forum Programming
    Replies: 8
    Last Post: 11-08-2011, 11:02 AM
  5. Sorta Random Serial Number Generator
    By Cuselco in forum Programming
    Replies: 3
    Last Post: 08-27-2010, 12:05 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