Results 1 to 3 of 3
  1. #1
    Paroxuno is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Oct 2017
    Posts
    2

    Closing Access Submits Form Data Unintentionally

    Hello,
    I have a form linked to a Sharepoint list which works great, the only problem I have is that if you close out of Access (using the X on Access itself), it submits any partial data that has been entered into the form. In the form itself I have submit and close buttons and the x for the form is disabled. The submit buttons within the form have code tied to them to validate that the needed fields have been entered.

    I have no code tied to any 'on close' event for the form. How do I prevent any data from being recorded when someone closes Access using the x button?
    I do not believe I am able to use an 'on close' event either, since one of my buttons submits the data, closes the form, and opens a new one.



    ​​​​​​​Thank you.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,831
    Just a suggestion

    in the form module create a public Boolean called say doUpdate

    in the form open event put: doUpdate=False

    in the submit button click event put: doUpdate=True

    in the form beforeupdate event put: Cancel=not doUpdate

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Another way to do this is to open the form as modal, meaning that while the form is open, Access cannot be closed. If fact, while a modal form is open, clicking anywhere outside of it will have no effect.

    If you are using DoCmd.OpenForm to open the form, it looks like this:

    DoCmd.OpenForm "formname", , , , , acDialog

    If you are opening it from the navigation pane, set both the Modal and Popup properties to Yes

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

Similar Threads

  1. Closing Form Without Saving Data
    By Eranka in forum Access
    Replies: 5
    Last Post: 01-03-2018, 01:34 AM
  2. Closing form without saving data
    By Thompyt in forum Programming
    Replies: 5
    Last Post: 03-28-2015, 02:55 PM
  3. Combo Box on form updates unintentionally
    By zipmaster07 in forum Forms
    Replies: 2
    Last Post: 03-06-2012, 10:21 PM
  4. Closing a Form Based on Table Data
    By perihelia in forum Programming
    Replies: 2
    Last Post: 03-05-2012, 05:33 PM
  5. Replies: 3
    Last Post: 06-02-2011, 07:40 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