469,090 Members | 1,326 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,090 developers. It's quick & easy.

how to pull the correct answer from multiple choice questions database?

mb60
36
sir
In my database I have one column for question. Four columns are meant for options 1,2,3,4. The 5th column is YES/NO column.
The answers for the questions are entered into 5th column by a option box.
Now I would like to print a report with the questions and correct answers which are present in the 1,2,3,4 columns.
Example
Q) aaaaaaaaaaaaaaaaa
1) bbbbbbbb 2) cccccc 3) ddddd 4) eeeeeee
answer = 2

I would like to have the question answer in the report as given below
Q) aaaaaaaaaaaaaaaaa
answer = 2) cccccc

Thank you
Jan 25 '10 #1

✓ answered by NeoPa

Thank you.

The Choose() function would be something like line #9 :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Question],
  2.        [ID],
  3.        [1],
  4.        [2],
  5.        [3],
  6.        [4],
  7.        [Answer],
  8.        [Select],
  9.        Choose([Answer],[1],[2],[3],[4]) AS AnswerText
  10.  
  11. FROM   [QuestionBank]
  12.  
  13. WHERE  [Select]

7 4009
NeoPa
32,159 Expert Mod 16PB
I understand your question, but I have no reference points included from which to give you an answer. I would suggest using the function Choose(), but I would require the SQL you have so far to provide a more helpful usage example of the function.
Jan 25 '10 #2
mb60
36
Thank you sir
where I have to place that function in the database?
I don't know anything about SQL
Jan 25 '10 #3
NeoPa
32,159 Expert Mod 16PB
And I (still) no nothing about your SQL. Please reread my last post to find out what you need to do to get more help. To clarify further, see below :
To extract the SQL from a QueryDef (saved Access query) it is only necessary to view the query in SQL View. This shows the underlying SQL for the QueryDef and is text (See Access QueryDefs Mis-save Subquery SQL for problems with SubQueries). When a QueryDef is open (either in Design View or Datasheet View) it is possible to switch to the SQL View simply by selecting View \ SQL View from the menu.

From here it is simple to Copy & Paste it to wherever you need it.
Jan 25 '10 #4
mb60
36
sir
As you directed I extracted SQL and pasting here
Expand|Select|Wrap|Line Numbers
  1. SELECT questionbank.question, questionbank.ID, questionbank.[1], questionbank.[2], questionbank.[3], questionbank.[4], questionbank.answer, questionbank.[select]
  2. FROM questionbank
  3. WHERE (((questionbank.[select])=-1));
Jan 25 '10 #5
NeoPa
32,159 Expert Mod 16PB
Thank you.

The Choose() function would be something like line #9 :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Question],
  2.        [ID],
  3.        [1],
  4.        [2],
  5.        [3],
  6.        [4],
  7.        [Answer],
  8.        [Select],
  9.        Choose([Answer],[1],[2],[3],[4]) AS AnswerText
  10.  
  11. FROM   [QuestionBank]
  12.  
  13. WHERE  [Select]
Jan 25 '10 #6
mb60
36
Thank you sir
successfully I got what I want that result
I salute for your interest in solving such problems
No words to express my happiness
(pl ignore the mistakes if any, in my english)
Jan 26 '10 #7
NeoPa
32,159 Expert Mod 16PB
Very pleased to hear it.

We do try to ignore language problems, but sometimes it's hard to understand. This thread was no problem though.
Jan 26 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by carly | last post: by
1 post views Thread by Brian Byrne | last post: by
1 post views Thread by Night Air | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.