close form without save

thrust

Registered User.
Local time
Today, 18:11
Joined
Jan 2, 2009
Messages
18
The form is always saving when i press the button i created with the close action. I use Access 2007. How can i just close the form without saving the possible changes that have been made to it?
Great thanks for any help.
 
The basic command behind the button is ...

Code:
DoCmd.RunCommand acCmdUndo
DoCmd.Close

If you want to give the user a choice, you could use something like ...

Code:
Dim sMsg As String
Dim iResponse As Integer
 
If Me.Dirty = True Then
     sMsg = "Changes have been made to this form." & vbCrLf & _
           "Would you like to save the changes when exiting?"
      iResponse = MsgBox(sMsg, _
           vbYesNo + vbQuestion + vbDefaultButton1, "Save Changes")
      Select Case iResponse
      Case vbYes
           DoCmd.RunCommand acCmdSaveRecord
           DoCmd.Close
           
      Case vbNo
           DoCmd.RunCommand acCmdUndo
           DoCmd.Close
       End Select
Else
       DoCmd.Close
End If

-dK
 
Thank you very very much. You helped a lot.
 
You bet .. good luck with your project.

-dK
 

Users who are viewing this thread

Back
Top Bottom