473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Jul 17 '05 #1
4 2856

"Mohammed Mazid" <ka******@hotmail.com> wrote in message
news:7c**************************@posting.google.c om...
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

Jul 17 '05 #2
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" <Wa*****@IntelligenCIA.com> wrote in message news:<aa*****************@nwrdny01.gnilink.net>...
"Mohammed Mazid" <ka******@hotmail.com> wrote in message
news:7c**************************@posting.google.c om...
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

Jul 17 '05 #3

"Mohammed Mazid" <ka******@hotmail.com> wrote in message
news:7c**************************@posting.google.c om...
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)
Jul 17 '05 #4

"Mohammed Mazid" <ka******@hotmail.com> wrote in message
news:7c**************************@posting.google.c om...
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)

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: john woo | last post by:
Hi I'm not good at JS, but want to get more about it. I want to use a JSP (the java code just used to get date, the rest are html and javascript), to display a table. the requirement is the...
4
by: Vincent Yang | last post by:
I'm using Access 2002. My database is in Access 2000 format. I'm designing a form to collect responses to a 40-item questionnaire. I can fit four list boxes on a screen, so I plan to have 11 tab...
2
by: Anand Ganesh | last post by:
Hi All, How to Implement Move Next, Move Previous, Last Record and First Record in a DataGrid Control ? Is there any standard tool available in the tool box button? Thanks for your time. ...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
24
by: Ian Rastall | last post by:
I do a site where I have a previous and next link at the bottom of every page. It looks like: <p><a href="foo01.html">Previous</a> | <a href="foo03.html">Next</a></p> Seeing as they're always...
2
by: ashasprabhu | last post by:
hai, How to move records to next and previous in asp.net as we do in VB6.0
2
TMS
by: TMS | last post by:
Schools over!!! Now its time to play. I would like to learn how to make objects move from one location to the next on a canvas widget. For example: from Tkinter import * class square:...
3
by: dianaj86 | last post by:
I have multiple dropdownlists each one filled with values from a specific column in the table. Also I have multiple textboxes corresponding to dropdownlists. For example, when I select an item from...
4
by: pgcn | last post by:
Hi Using A2003 My db has main form with stakeholderID & other main details. When there are a number of detail subform records it often requires two clicks of the next/previous nav buttons...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.