473,581 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

"Mohammed Mazid" <ka******@hotma il.com> wrote in message
news:7c******** *************** ***@posting.goo gle.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_Cli ck()
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*****@Intell igenCIA.com> wrote in message news:<aa******* **********@nwrd ny01.gnilink.ne t>...
"Mohammed Mazid" <ka******@hotma il.com> wrote in message
news:7c******** *************** ***@posting.goo gle.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_Cli ck()
rs.MovePrevious
End Sub

Jul 17 '05 #3

"Mohammed Mazid" <ka******@hotma il.com> wrote in message
news:7c******** *************** ***@posting.goo gle.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.AbsolutePosi tion + 1 (for next) and
rs.Recordset.Ab solutePosition - 1 (for previous, ensuring you're not
already on number 1)
Jul 17 '05 #4

"Mohammed Mazid" <ka******@hotma il.com> wrote in message
news:7c******** *************** ***@posting.goo gle.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.AbsolutePosi tion + 1 (for next) and
rs.Recordset.Ab solutePosition - 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
5308
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 all rows in even number in light-blue, rows in odd number in light gray, when a mouse clicks on a row, this row gets highlighted and in yellow, and...
4
9513
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 pages (one page at the end for collecting identifying information) on my form. To ease the task for the user, I'd like to have an automatic...
2
8789
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. Regards Anand Ganesh
10
3072
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 config does specify a machinekey setting: <machineKey...
24
2834
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 in sequential order, is there a way to automagically go to the previous file or the next file using JS? Ian --
2
5591
by: ashasprabhu | last post by:
hai, How to move records to next and previous in asp.net as we do in VB6.0
2
18262
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: def __init__(self, canvas, xy, color, change): self.canvas = canvas self.id = self.canvas.create_rectangle(-10-abs(change),
3
14399
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 dropdownlistA, all the textboxes are filled with the first row values that contains that selected item and gives the number of rows containing this...
4
1759
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 to move to the next/ previous record. (regardless of whether or not the subfrm is dirty).
0
8304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6553
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5364
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3805
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.