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?
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