I have a save function setup and would really like to keep the built in close button as you would have on any other program.
Just to make the program easy to use.
This is what I have setup on the before update and on close events. What I would like when someone selects the close button that it brings up a msg box that asks if they would like to save Yes/No if no selected then the data wont be updated and it will close if they select yes it will save and close.
Can any one help me please???
Just to make the program easy to use.
This is what I have setup on the before update and on close events. What I would like when someone selects the close button that it brings up a msg box that asks if they would like to save Yes/No if no selected then the data wont be updated and it will close if they select yes it will save and close.
Can any one help me please???
Code:
[B]Before Update[/B]
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
If Me.txtProperSave.Value = "No" Then
Beep
MsgBox "Please Save This Record!" & vbCrLf & vbLf & "You can not advance to another record until you either 'Save' the changes made to this record or 'Undo' your changes.", vbExclamation, "Save Required"
DoCmd.CancelEvent
Exit Sub
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
If Err = 3020 Then 'Update or CancelUpdate without AddNew or Edit
Exit Sub
Else
MsgBox Err.Number, Err.Description
Resume Exit_Form_BeforeUpdate
End If
End Sub
[B]On Close[/B]
Private Sub Form_Close()
On Error GoTo Err_Form_Close
'Prompts the user to save the current record if it needs to be saved.
If Me.Dirty Then
Beep
MsgBox "Please Save This Record!" & vbCrLf & vbLf & "You Can Not Close This Form Until You SAVE or UNDO Your Changes.", vbExclamation, "Save Required"
Exit_Form_Close:
Exit Sub
Err_Form_Close:
MsgBox Err.Description
Resume Exit_Form_Close
End If
End Sub