Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to delete empty rows created in MS Access using vb6 coding
I have created only 28 records of data but totally 81 records have been created how to delete them

i have used rs.delete but couldn't delete them

Thank You

What I have tried:

VB
Dim name, nme As String
    rs.MoveFirst
    Do
    If rs.EOF = False Or rs.BOF = False Then
    
        If rs!nameoftest = Null Then rs.delete
        nme = rs!nameoftest
        name = CInt("&H" & nme)
        
        Select Case name
        Case name
            If name = 0 Then
                If Label27.Caption = glucose.Caption Then
                    display
                    If Text6.Text > 1 Then
                    Form9.Show
                    End If
                End If
            ElseIf name = 7 Then
                If Label27.Caption = chol.Caption Then
                    display
                    If Text6.Text > 1 Then
                    Form9.Show
                    End If
                End If
Posted
Updated 10-May-18 2:29am
v2
Comments
Richard Deeming 10-May-18 12:30pm    
If rs.EOF = False Or rs.BOF = False Then

With the exception of an empty recordset, can you describe a situation where you think this condition will not be met?

1 solution

Instead of looping the data, why not create a DELETE Statement (Microsoft Access SQL) [Access 2007 Developer Reference][^] and execute it using Connection.Execute Method (DAO)[^]

The code you've posted seems to be only partial so it's hard to give any exact suggestions about the DELETE statement nor about the rs.Delete.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900