【译文】如何在保存一个记录前提示用户
时 间:2013-10-29 08:15:24
作 者:周芳 ID:24526 城市:上海
摘 要:使用BeforeUpdate事件提示用户确认他们每次保存一条记录在一个表单时里的变化
正 文:
来自:微软 翻译:周芳
【译文】如何在保存一个记录前提示用户
下面的例子说明了如何使用BeforeUpdate事件提示用户确认他们每次保存一条记录在一个表单时里的变化。
VBA代码:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' 指定要显示的消息.
strMsg = "你想要保存更改吗?" & Chr(10)
strMsg = strMsg & "单击Yes以保存或没有放弃更改."
' 显示消息框.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "保存记录?")
' 检查用户的响应.
If iResponse = vbNo Then
' 撤消修改.
DoCmd.RunCommand acCmdUndo
' 取消更新.
Cancel = True
End If
End Sub
原文:How to: Prompt a User Before Saving a Record
The following example illustrates how to use the BeforeUpdate event to prompt users to confirm their changes each time they save a record in a form.
VBA
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
Cancel = True
End If
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)