I don't know what's causing this, but every time I have a do..while loop and the statements inside is quite long, I get an error "Loop without Do". Here is an example of my code..

PS: I know this code segment isn't efficient but this is how i code, do things individually before trying to optimize my code( by combining ifs etc..). I find debugging easier doing this. :)

Do While Not frmView.db1.Recordset.EOF
    bCheck = True
    If chkCCIF.Value = True Then
        If Not txtCCIF_r.Text = Left(frmView.db1.Recordset!CCIF_No, Len(txtCCIF_r.Text)) Then
            bCheck = False
        End If
    End If
    If chkCompany.Value = True And bCheck = True Then
        If Not txtCompany_r.Text = Left(frmView.db1.Recordset!Company, Len(txtCompany_r.Text)) Then
            bCheck = False
        End If
    End If
    If chkProduct.Value = True And bCheck = True Then
        If Not txtProduct_r.Text = Left(frmView.db1.Recordset!Product_Name, Len(txtProduct_r.Text)) Then
            bCheck = False
        End If
    End If
    If chkStatus.Value = True And bCheck = True Then
        If Not strStatus = frmView.db1.Recordset!Status Then
            bCheck = False
        End If
    End If
    If bCheck = True Then
        lstReport.AddItem frmView.db1.Recordset!CCIF_No
    frmView.db1.Recordset.MoveNext
Loop

Recommended Answers

All 2 Replies

That error is telling you that you missed a closing statement of some sort within the loop if not the closing statement of the loop itself and in this case you missed and End If to the last If bCheck = True Then statement...

Good Luck

Ohh... missed that. thanks!

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.