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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.