Results 1 to 3 of 3
  1. #1
    aaronmire99 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2021
    Posts
    1

    Subform records are being saved even if form is closed out of


    I'm sure this has been answered before but I am trying to create a simple inventory system and I have an intersection table between Product and Supply Order because the relationship is many-to-many. I have a form for the user to enter the supply invoice number as well as all the products that arrived in this order (see attached). I want the quantity of the product we have in stock to increase when the form is saved. For ex: we have 65 pieces of part 'abc' and 10 more arrive so I want the quantity of 'abc' in the Product table to be 75. I'm encountering a problem because it is creating the records before I even click the save button. The 'Product-Supply Order' records are added when I move to the next line. Even if I close out of the form, those records remain. So my 'AfterInsert' macro for that table is triggered after every line instead of once at the end after hitting save. Any way to fix this? Or is there a much easier way to do this? Got to be an easier way to update the quantity after the records are created. Sorry....very new at this.
    Click image for larger version. 

Name:	Supply Order Form.PNG 
Views:	10 
Size:	24.9 KB 
ID:	44188

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    9,171
    When you move off of a record, it is saved, barring any issues. Moving off can be done in a few ways: navigate to another record on a continuous or single form, or even move off of a subform onto the main form, all which happens behind the scenes. Sometimes the only ways to avoid this are unbound forms or forms based on staging tables, where nothing is saved into the main tables until all is well.

    Your biggest issue is that you should not be storing stock quantity calculations. The count should be derived from the INS minus the OUTS. See what you think of this before continuing on your current path
    http://allenbrowne.com/casu-14.html
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,813
    FYI, I deleted your duplicate thread. There is no need to post the same question in multiple forums, people who answer questions check them all.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 07-28-2016, 10:10 AM
  2. Replies: 4
    Last Post: 08-26-2014, 09:55 AM
  3. Replies: 5
    Last Post: 09-26-2013, 08:35 AM
  4. Replies: 4
    Last Post: 08-17-2011, 05:30 AM
  5. Losing Records Saved From Form
    By ProgZ in forum Forms
    Replies: 2
    Last Post: 04-17-2011, 11:32 PM

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 - Senior Forums