Results 1 to 2 of 2
  1. #1
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142

    Requery Parent Form Control Without Requerying Whole Form

    I have a main form called Quotes, and a subform called QuoteDetails (in datasheet view). And each with their respective tables. FYI That's a "quote" as in pricing for an estimate to a customer.



    The main form has a textbox called txtTotalPrice, it's control source =DSum( appropriate fields in the quote details )

    I would like my txtTotalPrice to reflect the total price as records are added/changed in the subform. in the subform's AfterUpdate event I placed the code
    Code:
    Me.Parent!txtTotalPrice.Requery
    And this does update the txtTotalPrice.

    My Problem is that when txtTotalPrice.requery is executed it actually just requeries the whole parent form (from what I can tell) and in doing so my subform current record jumps back to the first record. This sucks. Imagine working in a spreadsheet and everytime you hit enter it jumps back to the top of the sheet.

    How should I keep my txtTotalPrice updated in my parent form while not loosing my spot in the subform?

    PS:
    Unfortunately simply using a Total's row at the bottom of the subform's datasheet wont be satisfactory for my situation.

    EDIT (I figured it out):
    It dawned on me that my approach was wrong. I've had this problem else where before. The solution was to add txtPriceTotal text box in the form footer in the subform with a control source =Sum(...), not DSum. Then in the main form change the control source from the DSum function to just reference the price total text box in the subform. Now requering controls is no longer necessary and all works as it should.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad you got it working...but while I'm somewhat fuzzy as to your scenario (on new pain meds) I suspect using Recalc instead of Requery would have done the job.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 2
    Last Post: 11-15-2017, 08:51 AM
  2. Replies: 0
    Last Post: 07-24-2016, 04:45 AM
  3. Replies: 11
    Last Post: 04-09-2016, 08:54 PM
  4. Replies: 2
    Last Post: 04-08-2015, 04:06 PM
  5. Replies: 5
    Last Post: 03-17-2011, 06:21 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