Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b] Undo Form/Record Changes [/b]

Status
Not open for further replies.

scoobey

Technical User
Sep 18, 2001
32
GB
Hi all

I am looking to cancel all record changes on a form, but keep having issues with records still being saved.
I have a form which loads a table, with several records in the table. If I make a change to the first record, and then move on to the next record and make a change there (and so on), if I use my me.undo or form.undo button and close the form, the next time I open it it has only 'undone' the record I was last on, and not all subsequent ones.
Basically, I'm looking for a way to undo all changes on a form, regardless of how many records I have changed. A kind of 'super undo' button to undo all changes to all records on a form. Is this possible? Help - it's driving me mad!!!!
 
It's really NOT a good idea to post the same question in multiple forums. You may think it improves your chances of getting an answer, but it also irritates people that waste their time reading through the post only to find it is a duplicate. Go check the other thread - I already responded.


"Have a great day today and a better day tomorrow!
 
Sorry about that. I initially thought i'd put it into the wrong forum which is why I put it into this one.
 
Try the following, works well in subforms:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    ' Declare variables
    Dim strMsg As String

    ' Issue message to ask if they want to change the data
    strMsg = "Data has changed." & vbCrLf & vbCrLf & _
        "Do you wish to save changes the Record?" & _
        vbCrLf & vbCrLf & _
        "Click Yes to Save or No to Discard changes."
    
    ' Undo the changes if they do not want to save
    If Not Me.NewRecord And Me.Dirty Then
        If MsgBox(strMsg, vbYesNo, "Save Changes To Inspection") = vbNo Then
            Me.Undo
            Cancel = True
        Else

        End If
    End If
End sub


Mark Davies
Warwickshire County Council
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top