I have a datagrid with checkboxes that lets the user to multiple delete. How do I store the deleted records into a text file? I am using Access to store my data

My code for delete is


            For Each row As DataGridViewRow In DataGridView1.Rows
                If row.Cells(0).FormattedValue = True Then

                    Sql = "DELETE FROM member WHERE id = '" _
                    & CStr(row.Cells(1).FormattedValue) & "'"

                    With cmd
                        .Connection = con
                        .CommandText = Sql
                    End With
                    'Execute the Data
                    result = cmd.ExecuteNonQuery
                End If
            If result = 0 Then
                MsgBox("No Deleted Record.")
                MsgBox("The Record(s) has been deleted.")
            End If
        Catch ex As Exception
        End Try


You need to iterate over all cells BEFORE deletion. ie. foreach(Cell cell in row.Cells){...}
If row.Cells(0).FormattedValue = True Then
WriteCellValuesToFile(row); // new method
Sql = "DELETE FROM member WHERE id = '"

BTW: If result = 0 is AFTER the loop therefore is testing the LAST deletion.