删除记录的几种方法示例 Private Sub cmdDelete_Click() '删除当前记录 If Not Me.NewRecord Then RunCommand acCmdDeleteRecord MsgBox "当前记录已删除成功!", vbInformation, "提示" Else Me.Undo End If End Sub Private Sub Command45_Click() '删除选中记录 On Error Resume Next Dim strsql As String Dim intCount As Long intCount = DCount("id", "tbl前区统计指标", "删除 = -1") If intCount = 0 Then MsgBox "你还没选中记录,不能删除!", vbInformation, "提示" Exit Sub Else If (MsgBox("你真的要删除 " & intCount & " 条选中的记录吗?", vbQuestion + vbYesNo, "提示") = vbYes) Then strsql = "delete * from tbl前区统计指标 where 删除=-1" DoCmd.RunSQL strsql Me.Requery MsgBox "已删除 " & intCount & " 条选中记录!", vbInformation, "提示" Else Exit Sub End If End If End Sub Private Sub Command46_Click() '清除所有记录 Dim intCount As Long intCount = DCount("id", "tbl前区统计指标") If (MsgBox("你真的要删除所有( " & intCount & " 条)的记录吗?", vbQuestion + vbYesNo, "提示") = vbYes) Then strsql = "delete * from tbl前区统计指标" DoCmd.RunSQL strsql Me.Requery MsgBox "已删除所有( " & intCount & " 条)记录!", vbInformation, "提示" Else Exit Sub End If End Sub