Results 1 to 5 of 5
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    stop saving when going from mainform to subform

    I have a mainform and a subform. If I make a change in a field on the mainform and then click onto the subform, then said change in mainform is saved. Visa versa, a change in a field on the subform is saved once I click onto the mainform.



    I would prefer to not save in this manner but rather when I close the mainform I would get a prompt to save or not.

    Thanks

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,427
    That's how it's supposed to work. You could try using form BeforeUpdate event and cancel the update via a message box prompt I suppose. Info about that form event:
    https://docs.microsoft.com/en-us/off...reupdate-event

    IIRC, if you want to extend this to new records, you'll need the form BeforeInsert event.
    EDIT - if you want to be able to change either form and not be prompted until you close the main form, then the only solution I see is to unbind both forms. A lot of code for not much payback.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Code in BeforeUpdate events as Micron described

    or

    a single UNBOUND form and lots of code to load/save data from/to tables

    or

    two independent BOUND forms. Parent form would call the child form to open only after parent record is committed and then have to pass the key value to child form to save as foreign key in new records. Again, VBA will be involved but not as much as UNBOUND forms.
    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.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,942
    Your can also investigate using the begintrans, committrans methods

  5. #5
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Quote Originally Posted by Micron View Post
    You could try using form BeforeUpdate event and cancel the update via a message box prompt I suppose.
    That's what I chose to do, thanks.

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

Similar Threads

  1. Replies: 11
    Last Post: 06-21-2017, 01:51 PM
  2. Search subform from mainform
    By ittechguy in forum Programming
    Replies: 70
    Last Post: 10-04-2015, 06:08 AM
  3. Replies: 1
    Last Post: 11-07-2012, 05:31 PM
  4. Replies: 4
    Last Post: 03-30-2012, 01:47 AM
  5. Replies: 1
    Last Post: 11-29-2011, 01:37 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