See Also Example 1 Example 2 (Professional Edition Only)
Description
Deletes the current record In the Professional Edition, deletes a specified member from a collection .
Syntax
recordset.Delete
collection.Delete membername (Professional Edition Only)
Remarks
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 variable 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 TableDef or Index 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 Null 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.