Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Questions And Answers Database

Posted on 2003-03-12
8
Medium Priority
?
273 Views
Last Modified: 2006-11-17
Hi,

I am trying to design a Access database that can choose random questions from a table and randomly place the answers in no particular order.

Questions   Answers   Category  Section
---------   -------   --------  -------
Q_ID        A_ID      C_ID      S_ID
Q_Ctgy      A_QNo     C_Name    S_NumQs
Q_Code      A_Answer
Q_Question  A_Right
Q_Image
Q_Section

Note: Q_Ctgy links up with C_ID,
A_QNo links up with Q_ID.
Q_Section links up with S_ID.


For example, I have 4 sections. In each section (S_ID), a number of questions that are selected at random for each section (S_NumQs).

These questions must be random as per each section.

Each of the answers to each question must be at random also.

Is there a way to select random questions from the table and randomly place answers within the form?

 
0
Comment
Question by:BJunior
8 Comments
 
LVL 3

Expert Comment

by:RiverGuy
ID: 8124190
I don't think there is in Access like there is in SQL Server.  I would do this in VBA.  I would read the records into arrays, size the arrays to the count of the records, and then choose some random elements, finally displaying them on the form.
0
 
LVL 6

Expert Comment

by:TheAmigo
ID: 8124822
Sounds like there should be an easy way, but I just tried:
SELECT *
FROM Answers
ORDER BY Rnd();
and all rows get the same value for Rnd()... oh well.
0
 
LVL 8

Expert Comment

by:dovholuk
ID: 8124967
there is an "easy" way... all you need to do is this.

first, get the name of one of the fields in the table Answers. i'll pretend there's a field called QuestionNumber...

then just use this:

SELECT
     *
FROM
     Table1
ORDER BY
     Rnd(nz([QuestionNumber],0));


that way you'll be giving the RND() method a NEW SEED everytime you call it, that will force RND() to return a different random value each time...

give it a go, it should do what you want...

dovholuk
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Accepted Solution

by:
dovholuk earned 200 total points
ID: 8124972
of course that's supposed to be:

SELECT
    *
FROM
    Answers
ORDER BY
    Rnd(nz([QuestionNumber],0));


used table1 not answers in my post... dolt...

dovholuk
0
 
LVL 3

Expert Comment

by:RiverGuy
ID: 8128937
I never new the Rnd() function was aceesable Access as well.  Good info.
0
 
LVL 12

Expert Comment

by:nexusnation
ID: 8785625
Hi BJunior,
This question has been abandoned and needs to be finalized (102 days since last comment).

   You can accept an answer, split the points, or get a refund. Go to
   http://www.cityofangels.com/Experts/Closing.htm for information and options.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

nexusnation
EE Cleanup Volunteer for Microsoft Access
0
 
LVL 18

Expert Comment

by:1William
ID: 8889329
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, points to dovholuk
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

1William
EE Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:Mike_Metro
ID: 8896999
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question