Can anyone please help me on how to move to the next and previous
question?
Here is a snippet of my code:
Private Sub cmdNext_Click()
End Sub
Private Sub cmdPrevious_Cli ck()
showrecord
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 3
Check1(i).BackC olor = RGB(255, 255, 255)
Next
temstr = App.Path + "\testengine.md b"
Set db = OpenDatabase(te mstr)
initialise
End Sub
Sub initialise()
Dim i As Integer
Dim j As Integer
j = 0
Set rs = db.OpenRecordse t("Select QuestionNo From QMultiple Where
Selected = True Order By QuestionNo")
rs.MoveFirst
While rs.EOF = False
j = j + 1
selquestion(j) = rs!questionno
rs.MoveNext
Wend
showrecord (1) 'Show first question
End Sub
Function quizscore() As Integer 'Returnes user's current score
Dim score As Integer
Dim i As Integer
For i = 1 To 20
Set rs = db.OpenRecordse t("select solution from qmultiple where
questionno=" & selquestion(i))
If rs!solution = attempted(i - 1) Then
score = score + 1
Next
quizscore = score
End Function
Sub showrecord(n As Integer) 'Displays question with qno=n
Set rs = db.OpenRecordse t("select * from qmultiple where questionno="
& selquestion(n))
With frmQuiz
..lblQuestion = rs!question
..Check1(0).Cap tion = rs!ans1
..Check1(0).Val ue = Val(Mid(attempt ed(n - 1), 1, 1))
..Check1(1).Cap tion = rs!ans2
..Check1(1).Val ue = Val(Mid(attempt ed(n - 1), 2, 1))
..Check1(2).Cap tion = rs!ans3
..Check1(2).Val ue = Val(Mid(attempt ed(n - 1), 3, 1))
..Check1(3).Cap tion = rs!ans4
..Check1(3).Val ue = Val(Mid(attempt ed(n - 1), 4, 1))
..lblQNo.Captio n = n
End With
End Sub
I want to move to the next question using the cmdNext button and move
to the last question using the cmdPrevious button.
Thanks guys.
question?
Here is a snippet of my code:
Private Sub cmdNext_Click()
End Sub
Private Sub cmdPrevious_Cli ck()
showrecord
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 3
Check1(i).BackC olor = RGB(255, 255, 255)
Next
temstr = App.Path + "\testengine.md b"
Set db = OpenDatabase(te mstr)
initialise
End Sub
Sub initialise()
Dim i As Integer
Dim j As Integer
j = 0
Set rs = db.OpenRecordse t("Select QuestionNo From QMultiple Where
Selected = True Order By QuestionNo")
rs.MoveFirst
While rs.EOF = False
j = j + 1
selquestion(j) = rs!questionno
rs.MoveNext
Wend
showrecord (1) 'Show first question
End Sub
Function quizscore() As Integer 'Returnes user's current score
Dim score As Integer
Dim i As Integer
For i = 1 To 20
Set rs = db.OpenRecordse t("select solution from qmultiple where
questionno=" & selquestion(i))
If rs!solution = attempted(i - 1) Then
score = score + 1
Next
quizscore = score
End Function
Sub showrecord(n As Integer) 'Displays question with qno=n
Set rs = db.OpenRecordse t("select * from qmultiple where questionno="
& selquestion(n))
With frmQuiz
..lblQuestion = rs!question
..Check1(0).Cap tion = rs!ans1
..Check1(0).Val ue = Val(Mid(attempt ed(n - 1), 1, 1))
..Check1(1).Cap tion = rs!ans2
..Check1(1).Val ue = Val(Mid(attempt ed(n - 1), 2, 1))
..Check1(2).Cap tion = rs!ans3
..Check1(2).Val ue = Val(Mid(attempt ed(n - 1), 3, 1))
..Check1(3).Cap tion = rs!ans4
..Check1(3).Val ue = Val(Mid(attempt ed(n - 1), 4, 1))
..lblQNo.Captio n = n
End With
End Sub
I want to move to the next question using the cmdNext button and move
to the last question using the cmdPrevious button.
Thanks guys.
Comment