multi choise questions code

samm

Registered User.
Local time
Today, 09:25
Joined
Sep 19, 2003
Messages
27
Hi for all

I have multi choise questions Form

when I choose the answer on all groubs by option button, I want save all answer in text(T4) ,
My problem I get one answer only for last choose at the last groub in the text(T4)

The Main answer text is ( CORRECT ANSWER or WRONG ANSWER AND THE CORRECT ANSWER IS 64 xxxxxxxxxxxx

------------------------------------------
I used this code:

Option Compare Database

Dim intQ1, intQ2, intQ3 As Integer

Private Sub Frame1_AfterUpdate()
intQ1 = 0
Select Case Me!Frame1

Case 1
intQ1 = 1

Let T4 = " CORRECT ANSWER "

Case 2

Let T4 = "WRONG ANSWER AND CORRECT IS 30"
Case 3
Let T4 = "WRONG ANSWER AND CORRECT IS 30"

Case Else
MsgBox (“Error)

End Select
Me!T1 = dValue

T1 = intQ1 + intQ2 + intQ3

End Sub
----------------------------------
for example:

Q1. 5X5=
A 25
B 22
C 20

Q2. 5X6=
A 25
B 30
C 20

Q3 6X7=
A 42
B 44
C 56

when I select Q1 option A the text answer1(CORRECT ANSWER) come in T4

then I select Q2 option A the text answer2(WRONG ANSWER AND CORRECT IS B) come in T4 instead of text answer1 (CORRECT ANSWER)

then I select Q3 option A the text answer3(CORRECT ANSWER) come in T4 instead of text answer2 (WRONG ANSWER AND CORRECT IS A)

at the end I get only this text (CORRECT ANSWER) in T4

But I like to get all answer in T4 as:
answer1(CORRECT ANSWER)
answer2(WRONG ANSWER AND CORRECT IS B)
answer3(CORRECT ANSWER)
 
You are using the frame in your SELECT CASE. Typically the option buttons have values of 1, 2 and 3 (since you have 3). So anytime the first button is chosen, the value of the frame is 1, and then the CASE 1 option will be selected. Same with button 2 and 3, depends which is selected, not which contains the proper answer. You need to determine which button is selected (1, 2 or 3) and then compare that to which one has the proper answer (1, 2 or 3), then go from there.
 
samm said:
Dim intQ1, intQ2, intQ3 As Integer

Also, correct this:

Dim intQ1 As Integer, intQ2 As Integer, intQ3 As Integer
 
Thanks To FoFa and Mile-O-Phile

Main problem, How I save ALL ansewers.
T4 as a result page.

When I answer 100 Questions, in the result page(T4) I get save only last answer but should I have all answer.

To FoFa
About value is ok work perfectly I get score for any right answer in T1.

To Mile-O-Phile
I used your code: Dim intQ1 As Integer, intQ2 As Integer, intQ3 As Integer
but still save only one answers ( last answer main last optin I click)

better repeat all code for the form

Option Compare Database
Dim intQ1 As Integer, intQ2 As Integer, intQ3 As Integer

Private Sub Frame1_AfterUpdate()
intQ1 = 0
Select Case Me!Frame1

Case 1
intQ1 = 1


Let T4 = T4 & vbCrLf & " CORRECT ANSWER "

Case 2



Let T4 = T4 & vbCrLf & "WRONG ANSWER AND CORRECT IS 30"
Case 3
Let T4 = T4 & vbCrLf & "WRONG ANSWER AND CORRECT IS 30"

Case Else
MsgBox (“Error)

End Select
Me!T1 = dValue

T1 = intQ1 + intQ2 + intQ3

End Sub
Private Sub Frame13_AfterUpdate()
intQ2 = 0
Select Case Me!Frame13

Case 1
intQ2 = 1
Let T4 = " CORRECT ANSWER "
T4 = T4 & vbCrLf & "CORRECT ANSWER"
Case 2

Let T4 = "WRONG ANSWER AND CORRECT IS 42"
Case 3
Let T4 = "WRONG ANSWER AND CORRECT IS 42"

Case Else
MsgBox (“Error)

End Select
Me!T1 = dValue
T1 = intQ1 + intQ2 + intQ3

End Sub

Private Sub Frame22_AfterUpdate()
intQ3 = 0
Select Case Me!Frame22

Case 1

Let T4 = "WRONG ANSWER AND CORRECT IS 64 "

Case 2
intQ3 = 1
Let T4 = " CORRECT ANSWER "
Case 3
Let T4 = "WRONG ANSWER AND CORRECT IS 64"

Case Else

MsgBox (“Error)

End Select

Me!T1 = dValue
T1 = intQ1 + intQ2 + intQ3

End Sub
 
Last edited:
Dears
please I need your help !!!!!
 

Users who are viewing this thread

Back
Top Bottom