Results 1 to 6 of 6
  1. #1
    accesscoder is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    19

    Don't want to save forms on Refresh or closing

    Hello,



    I am a new access developer. I have noticed that when the form is dirty, if you refresh the form, or you press the 'cross' i.e close button on the form, it saves all the fields entered on the form, into the database. However I don't want my form to follow this default property. I want the form fields to be saved in the database, only after the user clicks the 'SAVE' button provided by me.

    How can I override the default access behavior and achieve what I want?

    I appreciate your help!

  2. #2
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Hm... I tried this silly code...

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If MsgBox("Do you want to save?", vbInformation + vbYesNo) = vbYes Then
        
        Else
            DoCmd.RunCommand acCmdUndo
        End If
    End Sub

  3. #3
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    The BeforeUpdate event is triggered when you close a form.

  4. #4
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    By the way, if you want the "saving of record" to be controlled programmatically, use DoCmd.RunCommand acCmdSaveRecord

  5. #5
    accesscoder is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    19
    Thank you, evander!

  6. #6
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Oh, you're welcome, and thanks for the reputation. It's my first time to get that one

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 08-05-2010, 04:17 PM
  2. Prevent a form from closing
    By ksmithson in forum Forms
    Replies: 0
    Last Post: 07-15-2010, 12:49 PM
  3. Closing the application with some timer
    By reachvali in forum Programming
    Replies: 1
    Last Post: 05-18-2010, 11:28 PM
  4. Compacting When Closing?
    By Sean04 in forum Access
    Replies: 5
    Last Post: 03-19-2010, 01:16 PM
  5. Closing a Form Problem
    By MuskokaMad in forum Forms
    Replies: 2
    Last Post: 03-18-2010, 05:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums