Results 1 to 4 of 4
  1. #1
    Gator777 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    2

    Random numbers


    I have the below code that generates a random number that will eventually be placed in a barcode. The code works great while you have the prgram open, however when you close it and then reopen it generates the same number as it did before it closed. Any ideas why this is happening?

    Code:
              
    Forms![main]!text143.value = 1 + int(100000 * rnd())

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You need to issue the Randomize() function to set the seed first.

  3. #3
    Gator777 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    2
    How would I code that in conjunction with my code?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    There is a good example of how to use in in VBA help. Have you looked there yet?

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

Similar Threads

  1. Rounded Numbers
    By TundraMonkey in forum Access
    Replies: 3
    Last Post: 08-11-2009, 12:19 PM
  2. Set Numbers equal to each other
    By ygu3 in forum Access
    Replies: 1
    Last Post: 07-16-2009, 07:34 PM
  3. random record
    By wasim_sono in forum Programming
    Replies: 1
    Last Post: 02-06-2008, 02:42 PM
  4. Insert Dash between set of Numbers
    By Jhankish in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:02 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