【译文】当用户删除一条记录时,显示一个自定义的对话框
时 间:2013-08-13 09:16:53
作 者:周芳 ID:24526 城市:上海
摘 要:当用户删除一条记录时,显示一个自定义的对话框
正 文:
来自:微软 翻译:周芳
【译文】当用户删除一条记录时,显示一个自定义的对话框
当你选择了一个窗体中的一条记录并要删除它,Access显示一个对话框询问用户是否确认删除记录。如果你需要的话,你可以有两种方式防止此对话框出现。你可以取消BeforeDelConfirm事件,在这种情况下,删除取消了。或者你可以设置响应参数的acDataErrContinue BeforeDelConfirm事件过程,在这种情况下,确认删除。
您可以使用一个BeforeDelConfirm事件过程显示一个自定义对话框来处理用户的响应。下面的例子演示了如何使用一个自定义对话框询问用户是否要取消或继续记录删除。
VBA代码如下:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Dim strMessage As String
Dim intResponse As Integer
On Error GoTo ErrorHandler
' Display the custom dialog box.
strMessage = "Would you like to delete the current record?"
intResponse = MsgBox(strMessage, vbYesNo + vbQuestion, _
"Continue delete?")
' Check the response.
If intResponse = vbYes Then
Response = acDataErrContinue
Else
Cancel = True
End If
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
原文:How to: Display a Custom Dialog Box When the User Deletes a Record
You can use a BeforeDelConfirm event procedure to display a custom dialog box and handle users' responses. The following example demonstrates how to use a custom dialog box to ask users whether they want to cancel or proceed with the record deletion.
VBA
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
Dim strMessage As String
Dim intResponse As Integer
On Error GoTo ErrorHandler
' Display the custom dialog box.
strMessage = "Would you like to delete the current record?"
intResponse = MsgBox(strMessage, vbYesNo + vbQuestion, _
"Continue delete?")
' Check the response.
If intResponse = vbYes Then
Response = acDataErrContinue
Else
Cancel = True
End If
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access高效办公】按日期...(06.12)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)

学习心得
最新文章
- Access快速开发平台--Acc...(06.16)
- 【Access高效办公】按日期区间...(06.12)
- Access快速开发平台--生成复...(06.07)
- 仓库管理实战课程(25)-导航菜单...(06.06)
- 仓库管理实战课程(24)-库存月结...(06.05)
- 分享一个简单的X氏家谱小示例(06.04)
- 仓库管理实战课程(23)-先入先出(06.02)
- 仓库管理实战课程(22)-代理商库...(05.30)
- 仓库管理实战课程(21)-安全库存...(05.28)
- Access快速开发平台--如何添...(05.26)