Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Deleting a Record from a Recordset - Visual Basic 6 (VB6)

The Recordset's Delete method will delete a record from the underlying data. Typically, you will want to take the record pointer to a different record after calling the Delete method. Before moving the record pointer, you should check the RecordCount property to make sure that at least one record is left in the Recordset.

After moving the record pointer, of course, you will need to check the Recordset's EOF property to make sure you haven't moved beyond the end of the data. If you have, you will want to call the MoveLast method—but first check the BOF property to make sure that there are any records at all remaining in the Recordset. The code for these operations might look like Listing 8.9.

LISTING 8.9
DELETING A RECORD

Private Sub cmdDelete_Click()
rsEmployees.Delete
rsEmployees.MoveNext
If rsEmployees.EOF Then
If rsEmployees.BOF Then
Msgbox ìNothing to Deleteî
cmdDelete.Enabled = False
Else
RsEmployees.MoveLast
End If
End If
End Sub

That particular example makes users aware of what they have done if they accidentally tried to delete from a Recordset that contained no records.

See Also


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved