1

MsgBox如果用户在提示下选择“否”,我正在尝试恢复到原始值。然而,这并没有发生。你能看看我哪里出错了吗?

Private Sub txtNov2_AfterUpdate()
Dim x As Integer
Dim NewValue As Integer
Dim OrigValue As Integer
NewValue = Me.txtNov2.Value
OrigValue = [Forms]![DataEntry]![txtNov2].OldValue 'Me.txtNov2.OldValue
If NewValue <> OrigValue Then
    x = MsgBox("Value Has Changed Do you Want to Update?", vbQuestion + vbYesNo, "Value Change")
    If x = vbYes Then
        MsgBox ("Please Press Update Button")
        btnUpdateData2.SetFocus
    Else
        txtNov2.SetFocus
        'Me.Undo
        txtNov2.Value = OrigValue
        'Cancel = True
    End If
End If
End Sub
4

1 回答 1

0

在我看来,您的代码正在运行,就目前而言。我打开表格...

原来的

...并将值从更改123124...

改变了

...然后当我按 [Tab] 键时,控件失去焦点时,我得到MsgBox...

消息框

...如果我选择“否”,则该值将恢复为123

还原

该状态和初始状态(当我第一次打开表单时)之间的唯一区别是表单仍然“脏”,如表单左侧记录选择器中的“铅笔”图标所示。如果您想完全撤消对表单的所有更改,请尝试替换...

Else
    txtNov2.SetFocus
    'Me.Undo
    txtNov2.Value = OrigValue
    'Cancel = True
End If

...和...

Else
    DoCmd.RunCommand acCmdUndo
End If
于 2013-04-14T10:13:18.977 回答