这是我刚用在订单录入子窗体中代码,测试OK!请把它贴在子窗体后
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim intAns As Integer
On Error Resume Next
intAns = MsgBox("记录已更改,你要保存吗?", vbYesNo + vbQuestion)
If intAns = vbNo Then
Cancel = True '取消窗体数据更新
DoCmd.RunCommand acCmdUndo '执行Undo操作,使记录回到未变更状态
End If