Results 1 to 5 of 5
  1. #1
    S400 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    6

    Question Can Commit / Rollback be added to a form to prevent update on Close [X] ?

    I have a form which allows only INSERT of a single row into a table.



    Problem is that it seems to write a record (as dirty data) as soon as it is loaded.
    The user is required to enter some fields for which there is validation coded.

    BUT.... if the user clicks on [X] (or does a right-click Close) then the dirty data stays in the table.

    Can I incorporate a Commit/Rollback function in the DoCmd Close event ?

    So that I can revalidate the data in the Close event, and if it is invalid then cancel the insert into the table?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Usual approach is to use form BeforeUpdate event to validate data and to cancel if it is not valid.

    Also, can disable form X close and shortcut menu with form properties. Disabling app X close and ribbon File>Close is more complicated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,007
    @June7
    O/P was asking what appears to be the same question and had assistance in this thread?
    https://www.accessforums.net/showthread.php?t=83679
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    S400 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    6
    Hi @June7,
    Not the same question as in earlier thread, but similar, as we were looking for options on how to prevent an update if a user closes a Form window without the data being entered & valid.
    Most development platforms I work on support a Transaction Integrity system in SQL with Commit/Rollback functions.
    So this question was to see if such an approach would be valid in MS Access.

    As it so happens, we have coded a solution which works without needing to employ Transaction Integrity - so this question is now moot.

  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    To answer your question directly, yes transactions are available;
    https://codekabinett.com/rdumps.php?...ss-transaction

    but not normally required, except in very specific situations, normally when updating multiple records.
    In your example of a single insert I can't see the point of adding the complexity.

    Assuming it is a small dataset it would probably be easier to create a small unbound form, only writing the insert when confirmed.
    Or much simpler using the form's before update as per the other thread.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 1
    Last Post: 11-28-2017, 07:28 AM
  2. Replies: 3
    Last Post: 08-26-2014, 12:52 PM
  3. Replies: 3
    Last Post: 03-10-2014, 08:51 AM
  4. Prevent right click on top of form to close
    By bjnorth in forum Access
    Replies: 2
    Last Post: 02-19-2014, 09:48 AM
  5. Replies: 4
    Last Post: 01-31-2014, 11:47 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