|
以前发过一个例子:删除数据表窗体多条记录并提示所选记录的信息,使用了记录集,比较麻烦。
其实还有更简单的办法,数据表或连续窗体均可:
方法一:
Option Compare Database
Option Explicit
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.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
方法二:
Option Compare Database
Option Explicit
Dim stDel As String
Dim inDel As Integer
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Response = acDataErrContinue
If MsgBox("您正准备删除 " & inDel & " 条编号如下的记录:" & Chr(13) & stDel & Chr(13) & _
Chr(13) & "删除后将不能撤消,确定删除吗?", vbExclamation + vbYesNo, "确认删除") = vbNo Then
Cancel = True
End If
End Sub
Private Sub Form_Delete(Cancel As Integer)
stDel = stDel & Chr(13) & " " & Me.编号
inDel = inDel + 1
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|