I am trying to give a warning message like in microsoft word. When the user made some change in the form, and then unload the form, I will give the user a message: exit and saved the changes, exit without saving, or cancel. Apparently, the exit without saving never works out. Here is my code:
If Me.DataIsChanged = -1 Then
Dim Msg, Style, Title, Response
' Define message.
Msg = "Do you want to save the changes you made to 'Turbosteam Service History Database'?"
Style = vbYesNoCancel + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Exiting Projects form" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
DoCmd.Close acForm, 2, acSaveYes 'Exit with the saving the changes
Else
If Response = vbNo Then
'DoCmd.Close acForm, 2, acSaveNo 'I tried to use this, but didn't work either
Me.ExitWithoutSaving
Else
DoCmd.CancelEvent 'Cancel exit action and go back to form
End If
End If
End If
Can anybody help please?
Dedi
If Me.DataIsChanged = -1 Then
Dim Msg, Style, Title, Response
' Define message.
Msg = "Do you want to save the changes you made to 'Turbosteam Service History Database'?"
Style = vbYesNoCancel + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Exiting Projects form" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
DoCmd.Close acForm, 2, acSaveYes 'Exit with the saving the changes
Else
If Response = vbNo Then
'DoCmd.Close acForm, 2, acSaveNo 'I tried to use this, but didn't work either
Me.ExitWithoutSaving
Else
DoCmd.CancelEvent 'Cancel exit action and go back to form
End If
End If
End If
Can anybody help please?
Dedi