我的表单名称是[显示运输历史],子表单名称是[发货历史子表单],其记录源指向名为“My-Shipping-History”的表。我在主窗体上有一个“删除录制”按钮,我希望通过单击它从“我的航运历史”表中删除所选录制。谁能让我知道如何实现这一目标?
您可以在按钮的OnClick事件中插入此代码:
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