Results 1 to 6 of 6
  1. #1
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42

    OrderItems subform not updating when a user adds an item

    Hello All,

    I have an orders form with a button where users can Add Items to the order. Beneath the button is a datasheet subform that’s built off a query that shows all the items in the order. I got the idea from an Order template I saw online.



    It works well, except that when a user adds and item, the datasheet subform doesn’t update unless I close the Orders form and reopen it. At one time I had it working, so I’m not sure what happened.

    Basically, the user clicks the Add Item button and a popup form appears where they can select a Product and Quantity before clicking “Save & Close”. That subform is bound to the OrderItems table, and the OrderID is passed to that popup subform via OpenArgs. All of the references appear in good shape, and the query itself shows the right data, it just doesn’t update the order items subform when a user clicks “Save & Close”. I have to completely close the Orders form and reopen it before I can see the newly added items.

    Does anyone know what I’m doing wrong?

    See below a screenshot of my form:
    Click image for larger version. 

Name:	order.jpg 
Views:	14 
Size:	42.8 KB 
ID:	32784

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you need to requery the subform at the end of your 'save and close' code in order to show the newly added data

    on the basis this is in a separate form it will be something like

    forms!myform.form.subformcontrolname.requery

  3. #3
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by Ajax View Post
    you need to requery the subform at the end of your 'save and close' code in order to show the newly added data

    on the basis this is in a separate form it will be something like

    forms!myform.form.subformcontrolname.requery
    Thank you for your reply! Right now, the "Save & Close" button uses an Embedded Macro for it's on-click event. That Macro is set to save the record and close the form, since I didn't know how to do this in VBA. Do I need to re-write that code in VBA and add the code you suggested? Or is there a way to keep the existing Macro event and add this as well?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    regret I don't use macros, way to limiting so cannot advise - but perhaps see if there is a requery action?). There is an option on the ribbon to convert macros to vba.

  5. #5
    PrimaryKey is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    42
    Quote Originally Posted by Ajax View Post
    regret I don't use macros, way to limiting so cannot advise - but perhaps see if there is a requery action?). There is an option on the ribbon to convert macros to vba.
    Thank you for the reply Ajax. Unfortunately, the option to convert the Macro to VBA is greyed out when I open the macro. Not sure why.

    I still haven't figured out a way to do this. I created a requery button on the main form that allows the OrderItems subform to be refreshed, but I still can't figure out how to attach that action to the button I need to attach it to, in part because it already has a macro event.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    the option to convert the Macro to VBA is greyed out when I open the macro
    are you creating a web app?

    but I still can't figure out how to attach that action to the button I need to attach it to, in part because it already has a macro event.
    as I said, I don't use macros, but I know enough that you can add more than one command to a macro

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

Similar Threads

  1. Replies: 2
    Last Post: 07-13-2016, 02:19 PM
  2. Replies: 1
    Last Post: 06-30-2016, 04:57 PM
  3. subform - only select item once
    By BigPat in forum Forms
    Replies: 7
    Last Post: 01-15-2016, 01:15 PM
  4. Replies: 2
    Last Post: 10-21-2014, 07:57 AM
  5. Replies: 0
    Last Post: 06-23-2009, 03:01 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