Preventing unwanted edits

Zorkmid

Registered User.
Local time
Today, 07:41
Joined
Mar 3, 2009
Messages
188
Hi there,

Me again!

I am trying to prevent my database from falling victim to unwanted/inadvertent edits. I have it set up so that there are command buttons in my subform (Im talking about a search form with a subform displaying results) that either cancel changes, or save them. There is a way to totally bypass this failsafe however. When someone makes changes in the subform and then closes the entire form using that little 'x' in the top right corner then the change is saved without any sort of prompt asking if the changes should be saved or discarded.


Any thoughts on closing this final loophole ?

-Z
 
In the form properties you can disable the "X" close button and but a close form command button instead there are also tutorials around on how to prevent users from closing a form unless certain criteria have been met.

Good luck - John
 
I have been looking but unable to find what I am looking for.

Playing with it for a bit I think I know wht I want to happen. I would like access to look at the ondirty property of the subform whenever the record is changed, or the form or subform is closed, and ask whether the changes should be saved or not. Does anyone know a bit of code to make this happen?

-Z
 
I have tried putting this code into my subform:

Code:
Private Sub Risk_Data_Query_subform_BeforeUpdate(Cancel As Integer)
    If Me.Dirty = True Then
        
        If MsgBox("Changes have been made to this record, do you wish to save these changes?") = vbNo Then
        'If no then undo unsaved changes:
        DoCmd.DoMenuItem acFormBar, acEditMenu, acUNDO, , acMenuVer70
        'Then close form:
        DoCmd.Close
        End If
    End If
    
End Sub

Doesnt seem to work though.

-Z
 

Users who are viewing this thread

Back
Top Bottom