删除记录的几种方法示例

  1. Private Sub cmdDelete_Click() '删除当前记录

  2. If Not Me.NewRecord Then

  3. RunCommand acCmdDeleteRecord

  4. MsgBox "当前记录已删除成功!", vbInformation, "提示"

  5. Else

  6. Me.Undo

  7. End If

  8. End Sub

  9. Private Sub Command45_Click() '删除选中记录

  10. On Error Resume Next

  11. Dim strsql As String

  12. Dim intCount As Long

  13. intCount = DCount("id", "tbl前区统计指标", "删除 = -1")

  14. If intCount = 0 Then

  15. MsgBox "你还没选中记录,不能删除!", vbInformation, "提示"

  16. Exit Sub

  17. Else

  18. If (MsgBox("你真的要删除 " & intCount & " 条选中的记录吗?", vbQuestion + vbYesNo, "提示") = vbYes) Then

  19. strsql = "delete * from tbl前区统计指标 where 删除=-1"

  20. DoCmd.RunSQL strsql

  21. Me.Requery

  22. MsgBox "已删除 " & intCount & " 条选中记录!", vbInformation, "提示"

  23. Else

  24. Exit Sub

  25. End If

  26. End If

  27. End Sub

  28. Private Sub Command46_Click() '清除所有记录

  29. Dim intCount As Long

  30. intCount = DCount("id", "tbl前区统计指标")

  31. If (MsgBox("你真的要删除所有( " & intCount & " 条)的记录吗?", vbQuestion + vbYesNo, "提示") = vbYes) Then

  32. strsql = "delete * from tbl前区统计指标"

  33. DoCmd.RunSQL strsql

  34. Me.Requery

  35. MsgBox "已删除所有( " & intCount & " 条)记录!", vbInformation, "提示"

  36. Else

  37. Exit Sub

  38. End If

  39. End Sub

1.《md如何删除、md删除固定针!》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。

2.《md如何删除、md删除固定针!》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。

3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/keji/3296000.html