Random test

P

Paul \(OMAC HX\)

Hi ,

I am wondering is it possible to set up a database where i can keep adding
questions to a table and then print out a random test from the questions
entered. like 30 random questions out of the database and thenprint them.

Also ifthis can be done what way would it have to be laid out soicould
alsogive the wuestion and 4 multiply choice answers with it also.

Thanks for any helpwith this

PAul
 
J

John W. Vinson

Hi ,

I am wondering is it possible to set up a database where i can keep adding
questions to a table and then print out a random test from the questions
entered. like 30 random questions out of the database and thenprint them.

You can use the Top Values property of a query, with help
from a little VBA. Put this little function into a Module:

Public Function RndNum(vIgnore As Variant) As Double
Static bRnd As Boolean
If Not bRnd Then
'Initialize the random number generator once only
bRnd = True
Randomize
End If
RndNum = Rnd()
End Function

Then add a calculated field to your Query by typing

Shuffle: RndNum([fieldname])

in a vacant Field cell, where [fieldname] is any field in
your table - this forces Access to give a different random
number for each record.

Sort the query by Shuffle, and set its Top Values property
to the number of records you want to see. Base your test report on this query.

Also ifthis can be done what way would it have to be laid out soicould
alsogive the wuestion and 4 multiply choice answers with it also.

Not sure! What's your table structure? Where would you get the answers? You
certainly would NOT want to pull four random answers from a table of all
answers; I've written tests and it's a lot of work to get one right answer and
three reasonable but not nastily tricky wrong answers appropriate to the
question.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top