1,105,585 Community Members

Visual Basic 6.0

Member Avatar
ShamSundar
Newbie Poster
1 post since Mar 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

People pls help me i am getting a compiler error - Loop Without Do
This is my Code

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Shyam\Documents\Database1.mdb;Persist Security Info=False"
cn.Open()
rs = New ADODB.Recordset
rs.Open("select* from STUDENTSWITHHOA", cn, adOpenKeyset, adLockOptimistic)

Do Until rs.EOF

    If rs!RegNo = Text2.Text Then
        If IsNull(rs("Name")) Then
            answer = MsgBox("The Register Number You Entered Didnt Provide All The Inforamtion Do you still Want to Display the Details", vbYesNo + vbExclamation, "Alert")
            If answer = vbYes Then
                Text1.Text = rs!Name
                Text3.Text = rs!MobileNo
                Text4.Text = rs!E_mailId
                Text5.Text = rs!ArrearYear
                Text6.Text = rs!ArrearSemester
                Text7.Text = rs!ArrearSubject
                Text8.Text = rs!HOA
                If answer = vbNo Then
                    Form1.Show()
                Else
                    rs.MoveNext()
                End If
Loop
MsgBox("THE REGISTER NUMBER U ENTERED DOES NOT HAVE HISTORY OF ARREARS")
rs.Close
Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
0
 

look at your code with a bit of formatting.

Do Until rs.EOF

    If rs!RegNo = Text2.Text Then
        If IsNull(rs("Name")) Then
            answer = MsgBox("The Register Number You Entered Didnt Provide All The Inforamtion Do you still Want to Display the Details", vbYesNo + vbExclamation, "Alert")
            If answer = vbYes Then
                Text1.Text = rs!Name
                Text3.Text = rs!MobileNo
                Text4.Text = rs!E_mailId
                Text5.Text = rs!ArrearYear
                Text6.Text = rs!ArrearSemester
                Text7.Text = rs!ArrearSubject
                Text8.Text = rs!HOA
                    If answer = vbNo Then
                        Form1.Show
                    Else
                        rs.MoveNext
                    End If

This Loop statement is isolated withing an if-then block without a Do Statement to pair with

                Loop


                MsgBox "THE REGISTER NUMBER U ENTERED DOES NOT HAVE HISTORY OF ARREARS"
                rs.Close

You can not isolate parts of statement pairs in another paired statement block like If-End IF.

Member Avatar
Reverend Jim
Noli mentula
5,472 posts since Aug 2010
Reputation Points: 770 [?]
Q&As Helped to Solve: 655 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
1
 

I reformatted your code. Notice how you are missing a few End If statements. Close your if blocks and you should be fine.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article