Undo Record 
Author Message
 Undo Record

Sorry to continue on this line of questioning but I have yet to find an
answer. What I want to be able to do is have the user make all the
changes he/she wants to a record and when the focus leaves that record
(clicking a button, going to next record, etc.) the user should get the
option to save the changes or not. The problem is, how do I undo the
saved record if the user selects no. Microsoft's page says to
CancelEvent and SendKeys Esc but this does not work because it tries to
cancel an event that can't be cancelled, such as FindRecord. If anyone
can help me with this problem it would be greatly appriciated.

Thanks in advance.



Mon, 13 Dec 1999 03:00:00 GMT  
 Undo Record

on the before update event type this

select case msgbox("Yes or No", vbYesNo)
        case vbNo
                Undo
                Undo
                cancel=true
end select

if the user clicks Yes it will save as usual
otherwise it will undo twice (there are two levels of undo)
and cancel the update

enjoy


Quote:
> Sorry to continue on this line of questioning but I have yet to find an
> answer. What I want to be able to do is have the user make all the
> changes he/she wants to a record and when the focus leaves that record
> (clicking a button, going to next record, etc.) the user should get the
> option to save the changes or not. The problem is, how do I undo the
> saved record if the user selects no. Microsoft's page says to
> CancelEvent and SendKeys Esc but this does not work because it tries to
> cancel an event that can't be cancelled, such as FindRecord. If anyone
> can help me with this problem it would be greatly appriciated.

> Thanks in advance.



Tue, 14 Dec 1999 03:00:00 GMT  
 Undo Record

This works for me...

1. In the '.BeforeUpdate' event for the form open a modal dialog or
message box that prompts the user "Save record?"

2. If the answer is NO then set cancel = True, and...

3. issue an "undo" command...

I know that you have probably done this--the trick is to place an "On
Error Resume Next" statement in the routine so that any errors generated
by the undo command don't crash things. The routine shown below does it
for me...

Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim rslt As Integer
    On Error Resume Next
    rslt = MsgBox("Save this record?", vbYesNo, "test...")
    If rslt = vbNo Then
        Cancel = True
        DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
    End If
End Sub

Hope this helps...

-cliff-

Quote:

> Sorry to continue on this line of questioning but I have yet to find
> an
> answer. What I want to be able to do is have the user make all the
> changes he/she wants to a record and when the focus leaves that record

> (clicking a button, going to next record, etc.) the user should get
> the
> option to save the changes or not. The problem is, how do I undo the
> saved record if the user selects no. Microsoft's page says to
> CancelEvent and SendKeys Esc but this does not work because it tries
> to
> cancel an event that can't be cancelled, such as FindRecord. If anyone

> can help me with this problem it would be greatly appriciated.

> Thanks in advance.



Mon, 27 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. "Undo"ing edited records

2. How to UNDO before record is saved?

3. Record change, undo

4. How to UNDO before record is saved?

5. Allow an UNDO set of records?

6. Selective Undo from the Undo List

7. Program Undo

8. Undo

9. Undo in On Error event

10. Undo last action

11. help required with Undo butten events

12. Creating a custom Undo solution?

 

 
Powered by phpBB® Forum Software