【译文】当用户删除一条记录时,显示一个自定义的对话框
时 间: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群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access窗体导出PDF】...(04.08)
- 【Access窗体导出PDF】...(04.07)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
- 通过Access宏录入数据到选...(11.10)
学习心得
最新文章
- ACCESS精华集锦资料.CHM(04.25)
- Access VBA语句If Me...(04.24)
- 【Access修改记录示例】编辑选...(04.22)
- 【Access表名称命名建议】将A...(04.20)
- Access学习笔记--用Acce...(04.19)
- 【Access重复项查询示例】将A...(04.17)
- Access快速开发平台企业版--...(04.16)
- 【Access模块示例】通过模块代...(04.15)
- Access查询里面分组合计功能添...(04.13)
- 【Access删除查询】删除数字最...(04.12)