Results 1 to 3 of 3
  1. #1
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596

    Bug in RND() function?

    Hi,
    I ran a program at work that required two random names be pulled on five different days from a set of about 250,000 names.
    The names are appended into a table from 5 different spreadsheets.
    The RND function is run using the high & low values from the ID [Auto Number] field.
    This is my code to get the random number:
    Code:
    intRandom = Int((intUpper - intLower + 1) * Rnd + intLower)
    On each of the days - the first number pulled at random had a Last Name beginning with "P" and the second number pulled had a LAst Name beginning with "L".
    I didn't spot the pattern - [I wasn't looking for a pattern at that point] -but when the Director for whom I did this program was typing up the report of all the names drawn on the 5 different days - the pattern was unmistakable.

    Can anyone think of what might have happened?



    I tried to re-create the problem and am not able to now.

    I should add that before the Form comes up with the button to click for the random names - three macros run:
    1. Delete existing data,
    2. Import data from spreadsheets
    3. Append data from spreadsheet imports to 'master' table.

    The last macro action is to open the Form.

    I'd appreciate any ideas/suggestions.

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Check out "Randomize".

    In describing RND, the initialization is barely mentioned, but for most applications, it is essential.

  3. #3
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Thanks, hertfordkc.
    This pointed me in the right direction - and I have a much better understanding of the RND() function in Access now than I did before.
    Your pointer led me indirectly to the Randomize statement in VBA and that has solved the problem.
    Thank you!

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

Similar Threads

  1. HELP with IIF function
    By lpfluger in forum Queries
    Replies: 3
    Last Post: 04-01-2011, 12:01 AM
  2. Help with AVG function
    By techexpressinc in forum Reports
    Replies: 1
    Last Post: 03-23-2010, 07:47 AM
  3. Function Help
    By th3spankst3r in forum Programming
    Replies: 12
    Last Post: 03-22-2010, 12:41 PM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. Sum Function Help
    By newbie in forum Reports
    Replies: 3
    Last Post: 06-30-2009, 05:32 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