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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo changes function

Status
Not open for further replies.

EckyThump

MIS
May 15, 2007
33
GB
I have some forms that also includes sub forms.
I would like a function in a module that I could call when clicking a button on the forms to ask the user if he wants to save changes or not.
I am using the following code, but it does not work.
Can anybody help?
Code:
Public Function SaveChanges(formname) As String
On Error GoTo Err_saveChanges_Click

If formname.Dirty Then
  If MsgBox("Do you wish to save?", vbOKCancel, "Save?") = vbCancel Then
    Forms!formname.Undo
  End If
End If
    
Exit_saveChanges_Click:
    Exit Function

Err_saveChanges_Click:
    MsgBox Err.Description
    Resume Exit_saveChanges_Click
End Function
 
Replace this:
If formname.Dirty Then
with this:
If Forms(formname).Dirty Then

and this:
Forms!formname.Undo
with this:
Forms(formname).Undo

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top