0
votes

My form name is [Show Shipping History] and sub form name is [Shipment-History subform] which has record source pointing Table called “My-Shipping-History”. I have a “Delete Rec” button on the main form and I want make it delete the selected record from table “My-Shipping-History” by clicking it. Can somebody give me an idea of how can I achieve this?

1
Take the tour and read How to Ask.ComputerVersteher

1 Answers

1
votes

You can insert this code in the OnClick event of button:

Dim fm As Form
Dim rs As DAO.Recordset

Set fm = Me!NameOfYourSubformCONTROL.Form
Set rs = fm.RecordsetClone

If rs.RecordCount > 0 Then
    ' Move to the current record of the subform.
    rs.Bookmark = frm.Bookmark
    ' Delete the record.
    rs.Delete
    rs.Close
End If