Move to the next question and return to the previous question - basic.visual
This is a discussion on Move to the next question and return to the previous question - basic.visual ; 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_Click()
showrecord
End Sub
Private Sub Form_Load()
Dim i As Integer
...
-
Move to the next question and return to the previous question
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_Click()
showrecord
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 3
Check1(i).BackColor = RGB(255, 255, 255)
Next
temstr = App.Path + "\testengine.mdb"
Set db = OpenDatabase(temstr)
initialise
End Sub
Sub initialise()
Dim i As Integer
Dim j As Integer
j = 0
Set rs = db.OpenRecordset("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.OpenRecordset("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.OpenRecordset("select * from qmultiple where questionno="
& selquestion(n))
With frmQuiz
..lblQuestion = rs!question
..Check1(0).Caption = rs!ans1
..Check1(0).Value = Val(Mid(attempted(n - 1), 1, 1))
..Check1(1).Caption = rs!ans2
..Check1(1).Value = Val(Mid(attempted(n - 1), 2, 1))
..Check1(2).Caption = rs!ans3
..Check1(2).Value = Val(Mid(attempted(n - 1), 3, 1))
..Check1(3).Caption = rs!ans4
..Check1(3).Value = Val(Mid(attempted(n - 1), 4, 1))
..lblQNo.Caption = 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.
-
Re: Move to the next question and return to the previous question
"Mohammed Mazid" <kadmazid@hotmail.com> wrote in message
news:7cfd7b4a.0401310328.42edb593@posting.google.com...
> Can anyone please help me on how to move to the next and previous
> question?
>
Private Sub cmdNext_Click()
rs.MoveNext
End Sub
Private Sub cmdPrevious_Click()
rs.MovePrevious
End Sub
-
Re: Move to the next question and return to the previous question
Although this approach is possible, my initial thoughts were using the
showrecord() function. I want to use the recordset object from that
function but can someone guide me how to.
Cheers.
"Raoul Watson" <WatsonR@IntelligenCIA.com> wrote in message news:<aaPSb.3290$KV5.3261@nwrdny01.gnilink.net>...
> "Mohammed Mazid" <kadmazid@hotmail.com> wrote in message
> news:7cfd7b4a.0401310328.42edb593@posting.google.com...
> > Can anyone please help me on how to move to the next and previous
> > question?
> >
>
> Private Sub cmdNext_Click()
> rs.MoveNext
> End Sub
>
> Private Sub cmdPrevious_Click()
> rs.MovePrevious
> End Sub
-
Re: Move to the next question and return to the previous question
"Mohammed Mazid" <kadmazid@hotmail.com> wrote in message
news:7cfd7b4a.0401311031.7e0e5b0e@posting.google.com...
> Although this approach is possible, my initial thoughts were using the
> showrecord() function. I want to use the recordset object from that
> function but can someone guide me how to.
>
> Cheers.
>
Your showrecord function builds a data set (your SQL "Select ..." statement)
To do this everytime someone moves to the previous or next record is GROSSLY
inefficient and is not doable using your code because ecverytime you go to
show2record, you destroy the dataset (by building another one).
If you want to do it this way, you need to build two dataset (one that will
remain untouched) and one for your showrecord (again, it's not efficient to
do it this way).
If you have two datasets, assuming the original one is "rs" then all you
need is (if you don't want to use MoveNext and MovePrevious)::
rs.AbsolutePosition + 1 (for next) and
rs.Recordset.AbsolutePosition - 1 (for previous, ensuring you're not
already on number 1)
-
Re: Move to the next question and return to the previous question
"Mohammed Mazid" <kadmazid@hotmail.com> wrote in message
news:7cfd7b4a.0401311031.7e0e5b0e@posting.google.com...
> Although this approach is possible, my initial thoughts were using the
> showrecord() function. I want to use the recordset object from that
> function but can someone guide me how to.
>
> Cheers.
Your showrecord function builds a data set (your SQL "Select ..." statement)
To do this everytime someone moves to the previous or next record is GROSSLY
inefficient and is not doable using your code because ecverytime you go to
show2record, you destroy the dataset (by building another one).
If you want to do it this way, you need to build two dataset (one that will
remain untouched) and one for your showrecord (again, it's not efficient to
do it this way).
If you have two datasets, assuming the original one is "rs" then all you
need is (if you don't want to use MoveNext and MovePrevious)::
rs.AbsolutePosition + 1 (for next) and
rs.Recordset.AbsolutePosition - 1 (for previous, ensuring you're not
already on number 1)
Similar Threads
-
By Application Development in forum Adobe Indesign
Replies: 3
Last Post: 02-07-2007, 07:04 AM
-
By Application Development in forum Adobe Indesign
Replies: 0
Last Post: 02-07-2007, 12:56 AM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 09-21-2004, 09:44 PM
-
By Application Development in forum basic.visual
Replies: 1
Last Post: 02-01-2004, 06:03 PM
-
By Application Development in forum Javascript
Replies: 2
Last Post: 10-08-2003, 09:40 PM