Me.Undo error "Property not Found"

  • Thread starter Thread starter bymarce
  • Start date Start date
B

bymarce

I have a form on which I want users to be warned if they try to chane a
record that was entered befor today. I wrote the following code and it works
but gives the error "Property Not Found" when no is clicked in the message
box. What's wrong? Thanks.
Marcie

Private Sub Program_BeforeUpdate
If DOC < Date Then
Dim Answer As Integer
Answer = MsgBox("Are you sure you want to change this value? ",
vbYesNo, "MLOBook Edit")
If Answer = vbNo Then
Me.Undo
End If
End If
 
bymarce said:
I have a form on which I want users to be warned if they try to chane a
record that was entered befor today. I wrote the following code and it
works
but gives the error "Property Not Found" when no is clicked in the message
box. What's wrong? Thanks.
Marcie

Private Sub Program_BeforeUpdate
If DOC < Date Then
Dim Answer As Integer
Answer = MsgBox("Are you sure you want to change this value? ",
vbYesNo, "MLOBook Edit")
If Answer = vbNo Then
Me.Undo
End If
End If


That's not a correctly formed declaration for a BeforeUpdate event
procedure -- there ought to be a Cancel argument. Did you copy and paste
that code, or type it in by hand? Set the Cancel argument to True to
prevent the focus from leaving the control.

If your form is unbound, the Undo method doesn't work. However, I don't
think it ought to raise an error.
 
Being on the BeforeUpdate event, the value hasn't actually changed to undo yet.

If you want to do this in beforeupdate, you can Cancel the update.

Instead of

Me.Undo

try

Cancel = True


I would think that in the AfterUpdate event the undo would work.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Back
Top