Delete

This method deletes a row from the recordset.

Syntax

recordset.Delete AffectRecords

Parameters

AffectRecords

Optional. The only valid value for AffectRecords is 1 (adAffectCurrent). Any other value generates a run-time error. This feature is present for compatibility with ADO for the desktop computer.

Remarks

Using the Delete method deletes the current record from the database. If the Recordset object does not enable record deletion, an error occurs.

A deleted record remains current until you move to a different record, after which the deleted record is no longer accessible.

Retrieving field values from the deleted record generates an error.

If the attempt to delete records fails, a run-time error occurs.

Example

The following code shows how to delete a record using the Delete method.

Dim rs
Set rs = CreateObject("adoce.recordset")
rs.Open "myTable", "", 1, 3
rs.MoveLast
'This statement deletes the current (last) record.
rs.Delete
'This statement moves the pointer to the
'first record in the recordset which removes
'the deleted record from the recordset.
rs.MoveFirst
rs.Update
rs.Close
Set rs = Nothing