Random Number Generator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table of 200 questions as follows...tblQUESTIONS(autonumber,question)

I have a button on a form that when clicked would like to ask the following:
How many questions do you need? and based on the answer, creates a table that contains
1 column that is populated w ith random autonumber values from the first table. The autonumber
can be used only once.

I have a pool of test questions and am trying to create a way to autogenerate tests that have the amount of questions I need and no question duplicated.

I hope this makes sense....

Any help would be greatly appreciated....
 
Private Sub Command1_Click(NoQuestions as Integer)
Dim I() As Integer
Dim J as Integer
Dim K As Integer
Dim L As Integer

Randomize

ReDim I(NoQuestions)

For J = 1 To NoQuestions
I(J) = Int(Rnd * 200) + 1
For K = 1 To J - 1
If I(J) = I(K) Then J = J - 1
Next
Next
For J = 1 To NoQuestions
For K = 1 To NoQuestions - 1
If I(J) < I(K) Then
L = I(J)
I(J) = I(K)
I(K) = L
End If
Next
Next
End Sub

This creates the numbers then sorts them in numerical order. At the end,
you can then put the information into a table based on the numbers in the
array.

Suzette

Gregory said:
I have a table of 200 questions as follows...tblQUESTIONS(autonumber,question)

I have a button on a form that when clicked would like to ask the following:
How many questions do you need? and based on the answer, creates a table that contains
1 column that is populated with random autonumber values from the first table. The autonumber
can be used only once.

I have a pool of test questions and am trying to create a way to
autogenerate tests that have the amount of questions I need and no question
duplicated.
 
See: ACC2000: How to Fill a Table with Random Records from Another Table
http://support.microsoft.com/?id=210616

Tom
_______________________________________


I have a table of 200 questions as follows...tblQUESTIONS(autonumber,question)

I have a button on a form that when clicked would like to ask the following:
How many questions do you need? and based on the answer, creates a table that
contains
1 column that is populated w ith random autonumber values from the first table.
The autonumber
can be used only once.

I have a pool of test questions and am trying to create a way to autogenerate tests that
have the amount of questions I need and no question duplicated.

I hope this makes sense....

Any help would be greatly appreciated....
 
Back
Top