|
原因是选择了新记录引起的,添加2句代码取消选择新记录即可。
Dim stDel As String
Dim inDel As Integer
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Response = acDataErrContinue
End Sub
Private Sub Form_Delete(Cancel As Integer)
If Me.SelTop + Me.SelHeight - 1 > Me.RecordsetClone.RecordCount Then
Me.SelHeight = Me.SelHeight - 1
End If
If Me.SelHeight > inDel Then
stDel = stDel & Chr(13) & " " & Me.编号
inDel = inDel + 1
Cancel = True
End If
If Me.SelHeight = inDel Then
If MsgBox("您正准备删除 " & inDel & " 条编号如下的记录:" & Chr(13) & stDel & Chr(13) & _
Chr(13) & "删除后将不能撤消,确定删除吗?", vbExclamation + vbYesNo, "确认删除") = vbYes Then
inDel = Me.SelHeight + 1
DoCmd.RunCommand acCmdDeleteRecord
End If
inDel = 0
stDel = ""
End If
End Sub |
|