Results 1 to 7 of 7
  1. #1
    xxdocxx is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2

    Randomize in Forms starts from same seed when opening form

    Hello Folks, I am very new to access and I have to fix a random test generator that an ex-employee created. The test generator will create test with randomly picked questions and answers. Unfortunately, when you close and reopen the generator it starts off with the same questions. I have tried using Randomize as a event procedure on load, but this is not working. Any help would be greatly appreciated.




    Doc

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I've never used this before - thanks for the link, Orange.

    What if you put a counter on the table where the questions are stored and every time you use a question add one to the counter, then each time you start the test start with the question with the lowest number?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    The secret is the use of RANDOMIZE.

    Here is an example

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : randomNumber
    ' Author    : Jack
    ' Created   : 11/18/2010
    ' Purpose   : To Generate Random numbers between and including a range of numbers.
    'Lo and Hi are the lowest and highest random numbers you wish to generate.
    '
    'The Randomize keyword is critical to getting different results for each Access session.
    '=======================================================================================
    '---------------------------------------------------------------------------------------
    ' Last Modified:
    '
    ' Inputs: N/A
    ' Dependency: N/A
    '------------------------------------------------------------------------------
    '
    Function randomNumber(Lo As Long, Hi As Long) As Long
    10       On Error GoTo randomNumber_Error
    
    30    Randomize
    40    randomNumber = Int((Hi - Lo + 1) * Rnd + Lo)
    
    50       On Error GoTo 0
    60       Exit Function
    
    randomNumber_Error:
    
    70        MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure randomNumber of Module AccessM"
    
    End Function

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This is great! Thanks

  6. #6
    xxdocxx is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2
    Thank you, but this did not help. Still starting all tests with same questions on load.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    You should show us some code then.

    If you randomize the record to start with (select a random question from your questions) then it should not be repeating. More info please.

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

Similar Threads

  1. Opening Forms Via Criteria
    By jlgray0127 in forum Forms
    Replies: 4
    Last Post: 03-31-2015, 07:26 PM
  2. Replies: 1
    Last Post: 07-11-2014, 01:31 PM
  3. Opening Forms Maximized
    By data808 in forum Forms
    Replies: 3
    Last Post: 04-29-2014, 04:37 PM
  4. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  5. Two forms opening the same form
    By MikeMairangi in forum Forms
    Replies: 5
    Last Post: 08-31-2011, 01:55 PM

Tags for this Thread

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