Delete Method Example

This example adds a new record to Orders.dbf (a dBASE IV table located in the C:\Program Files\Microsoft Office\Office folder) and then deletes the record.

Dim db As Database, rs As Recordset
Set newRecord = Worksheets.Add.Rows(1)
With newRecord
    .Cells(1).Value = 10047
    .Cells(2).Value = "FOODG"
    .Cells(3).Value = 333
    .Cells(4).Value = #8/1/95#
    .Cells(5).Value = 752.91
End With
Set db = _
    OpenDatabase("C:\Program Files\Microsoft Office\Office", _
    False, False, "dBASE IV")
Set rs = db.OpenRecordset("ORDERS.DBF", dbOpenTable)
rs.AddNew
With newRecord
    rs("ORDER_ID") = .Cells(1).Value
    rs("CUSTMR_ID") = .Cells(2).Value
    rs("EMPLOY_ID") = .Cells(3).Value
    rs("ORDER_DATE") = .Cells(4).Value
    rs("ORDER_AMT") = .Cells(5).Value
End With
rs.Update
MsgBox "The new record has been created."
Stop
rs.Move 0, rs.LastModified
rs.Delete
MsgBox "The record you just created has been deleted."
rs.Close
db.Close