How to stop the Loop for User Request using ADO connection 
Author Message
 How to stop the Loop for User Request using ADO connection

Hello,

Please help with how to stop the Loop for user request
using ADO.

As my application is offline examination. I need user to
choose the choices for the given question if the choice is
chosen and correct i have to move to the next record or
question..in which case my is not stopping to get the user
request for the next question.

I have tried rm.editmode , its not working...also i have
tried several other things also...please help me out as
iam new to VB.

Here is my code for you:

Private Sub Command1_Click()
   Dim cm As ADODB.Connection
   Dim cmm As String
   Dim sqm As String
   Dim rm As ADODB.Recordset
   cmm = "Provider=Microsoft.Jet.OLEDB.4.0;"
   cmm = cmm & "Data Source=C:\Documents and
Settings\sunda2s\My Documents\Exam.mdb;"
   cmm = cmm & "Persist Security Info=False"
   Set cm = New ADODB.Connection
   With cm
       .ConnectionString = cmm
       .Open
   End With
   sqm = "select
Question,choice1,choice2,choice3,choice4,correctAnswer
from exam2 where btogroup='" + adofrm.combo1.Text + "' and
levelno =" + adofrm.Combo2.Text
   Set rm = New ADODB.Recordset
   With rm
       .Open sqm, cm, asOpenForward, adLockReadOnly
       Do While Not rm.EOF
           MsgBox "after do while"
           MsgBox rm("correctAnswer")
           If (Option1.Value = True) Then
               If (StrComp(rm("correctAnswer"),
Option1.Caption, vbTextCompare) = 0) Then
                   MsgBox "answer is choice1"
                   rm.MoveNext
                   txtQuestion.Text = rm("question")
                   Option1.Caption = rm("choice1")
                   Option2.Caption = rm("choice2")
                   Option3.Caption = rm("choice3")
                   Option4.Caption = rm("choice4")

               Else
                   MsgBox "try again"
                   Command1.Refresh
               End If
           ElseIf (Option2.Value = True) Then
               If (StrComp(rm("correctAnswer"),
Option2.Caption, vbTextCompare) = 0) Then
                   MsgBox "answer is choice2"
                   rm.MoveNext
                   txtQuestion.Text = rm("question")
                   Option1.Caption = rm("choice1")
                   Option2.Caption = rm("choice2")
                   Option3.Caption = rm("choice3")
                   Option4.Caption = rm("choice4")
               Else
                   MsgBox "try again"
                   Command1.Refresh
                   MsgBox rm("choice1")
               End If
           ElseIf (Option3.Value = True) Then
               If (StrComp(rm("correctAnswer"),
Option3.Caption, vbTextCompare) = 0) Then
                   MsgBox "answer is choice2"
                   rm.MoveNext
                   txtQuestion.Text = rm("question")
                   Option1.Caption = rm("choice1")
                   Option2.Caption = rm("choice2")
                   Option3.Caption = rm("choice3")
                   Option4.Caption = rm("choice4")
               Else
                   MsgBox "try again"
                   Command1.Refresh
                   MsgBox rm("question")
               End If
           ElseIf (Option4.Value = True) Then
               If (StrComp(rm("correctAnswer"),
Option4.Caption, vbTextCompare) = 0) Then
                   MsgBox "answer is choice4"
                   rm.MoveNext
                   txtQuestion.Text = rm("question")
                   Option1.Caption = rm("choice1")
                   Option2.Caption = rm("choice2")
                   Option3.Caption = rm("choice3")
                   Option4.Caption = rm("choice4")
               Else
                   MsgBox "try again"
                   Command1.Refresh
               End If
           End If
           MsgBox "about to loop"
       Loop
   End With
   Set rm = Nothing
   cm.Close
   Set cm = Nothing
End Sub

Thanks and appreciated...



Mon, 28 Nov 2005 03:45:56 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How can I get Role for Current User from SQL Server using VB6 ADO connection

2. RDO connection stops working after installing ADO libraries

3. looping through tables with ADO connection object.

4. WINSOCKET - wrong protocol or connection state for the requested transaction or request

5. Using VB/ASP.net to save user requested web data

6. waiting for the users input - stop and start code-processing using events

7. Stop users from using right click?

8. stopping users from stopping background process

9. How to set ADO connections on user machines

10. HELP: ADO Connection String - User Level Security...

11. ADO Connection - Get User Name

12. ADO Multi User Connection

 

 
Powered by phpBB® Forum Software