Delete Method

See AlsolanDeleteSee                 Example 1lanDeleteX1>Low              Example 2 (Professional Edition Only)lanDeleteX2>Low


Deletes the current record1BNJB8X in a specified TableK31GNT or DynasetUDR386.  In the Professional Edition, deletes a specified member from a collection17X8LRK.



collection.Delete membername (Professional Edition Only)


The Delete method uses these parts:

Part                 Description


recordset          The Recordset property of a data control.  In the Professional Edition, can also be an object variableZ3R9Q5 identifying a Table or Dynaset.

collection          In the Professional Edition, a TableDefs or Indexes collection.

membername    In the Professional Edition, a string expression that is the name of an existing TableDef1T7W9BL or Index1L6K9K3 in the specified collection.


Before you use Delete, a record must be recognized as current in recordset or an error will occur.  To make a record current, use one of the Move or Find methods, or the Bookmark property.  In the Professional Edition, you can use the Seek method with a Table object.

In a Table, Delete removes the current record.  In a Dynaset and the data control's Recordset property, Delete sets the current record to Null1DDW7C0 and removes the current record from its underlying tables.

The deleted record remains current, but any references to it produce an error.  Until you move to another record, what was the next record remains the next record, and the previous record remains the previous record.  Once you move to another record, you can't make the deleted record current again.

To delete more than one record, it is faster to execute an action query.  For example, in a list of publishers, you can delete those from New York with this statement:

Data1.Database.Execute "DELETE FROM Publishers WHERE State = 'NY'"

In the Professional Edition, deleting a member of the TableDefs collection deletes the table and all data in the table.  You can't delete a Field from a Fields collection of a TableDef; but you can accomplish the same thing by creating a duplicate table without the Field, and then copying the data from the first Table into the new one.

To restore a deleted record, you must have used BeginTrans before using the Delete method, then you can use the Rollback method.