我想删除该表是子表的表中的行。这可能吗?我该怎么办?
谢谢
答案 0 :(得分:0)
肯定-执行适当的SQL delete
查询以清除构成该子窗体的记录源的表中的所有记录,作为按钮的On Click
事件处理程序的一部分,例如:
Private Sub YourButton_Click()
CurrentDb.Execute "delete from YourSubFormTable"
End Sub
删除数据后,您需要通过调用表单对象的'requery'方法来重新查询子表单:
Private Sub YourButton_Click()
CurrentDb.Execute "delete from YourSubFormTable"
YourSubForm.Requery
End Sub
答案 1 :(得分:0)
使用 DAO 。快速且自动的重新查询:
Private Sub DeleteButton_Click()
Dim Records As DAO.Recordset
Set Records = Me!NameOfYourSubformCONTROL.Form.RecordsetClone
If Records.RecordCount > 0 Then
Records.MoveFirst
While Not Records.EOF
Records.Delete
Records.MoveNext
Wend
End If
Records.Close
End Sub