Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:29:18+00:00 2026-06-12T23:29:18+00:00

How can I discard the content of a form when a user exits the

  • 0

How can I discard the content of a form when a user exits the application? If the user closes the form via button (e.g. to go back to the main form) this can be achieved with Me.Undo. But if he closes the whole application the current content is entered into the according table which is not as intended.
I also tried the on Close and on Unload events which are both not firing when the application is being closed.

edit: the on Close event shows strange behaviour. A MsgBox is being executed but the Me.Undo does somehow not work. (Maybe form content is being entered into the table before the event when the X is being clicked to exit the application?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:29:20+00:00Added an answer on June 12, 2026 at 11:29 pm

    Closing a form automatically triggers save of pending changes to the values of bound controls. You can’t intercept that save operation from the form unload or close events. And the only way I can find to intercept it at all is from the form’s before update and insert events:

    Dim SaveFlag As Boolean
    
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If Me.Dirty = True And SaveFlag = False Then
            Me.Undo
        End If
    End Sub
    

    You would need to do similar for before insert. And you would need to manage SaveFlag somehow so that you could actually save changes when you want them saved.

    Private Sub cmdSave_Click()
        SaveFlag = True
        Me.Dirty = False
        SaveFlag = False
    End Sub
    

    However, if you want Access’ default behaviors such as automatically saving changes when navigating between records or when switching focus between a main and sub form, this approach is not suitable.

    If you need this feature badly enough, you could switch to unbound data controls and only save their values when you explicitly order it to happen. But that would add a lot of extra work and I don’t know if it’s worth the effort. I would be tempted to treat this as a user education issue. “Be aware that if you close the application with unsaved changes in a form, the changes will be saved for you.“

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it clean enough that you can discard the PHP and hand-optimize the C++
Can we change the default action of the edit selected row button? Here is
Can anyone enlighten me to a way I can Highlight the content of an
I have a user interface where the user can check off a bunch of
After noticing an application tended to discard random emails due to incorrect string value
Well this kind of n00b question but I still can't figure it out. I
How to discard getting notified with files system: e.g: thumbs.db I have this instance
An user can post multiple comments in a thread, and I try to get
I have built a specialized card application. What it does is allow a user
I can't seem to get rid of untracked content in Git's submodules. Running git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.