Results 1 to 3 of 3
  1. #1
    SusanCoder is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Posts
    34

    requery subform1 after data field updates in subform2

    I'm attempting to requery/reload a subfrm when a field on another subfrm is updated. I've not yet found the correct vba code. Thanks for your help.

    I have three forms:
    • frmYouthInfo - Youth's UniqueID, name and address fields, etc. (source data from query of tblYouthInfo)
    • subfrmFunds - fields: DateOfService, Code, Amount. (source data from query of child table tblFunds, parent table tblYouthInfo, linked by the youth's UniqueID)
    • subfrmMaxLifetimeDriversEd - fields: Code, SumOfAmount (source data from query of child table tblFunds where Code="52DriversEd", parent table tblYouthInfo, linked by the youth's UniqueID)


    Both subfrms are on the same horizontal tab named Funds, located in the bottom portion of the frmYouthInfo. subfrmMaxLifetimeDriversEd will show the sum (SumOfAmount) of all entries on the subfrmFunds where code = "52DriversEd", so the staff can easily see when a youth has used their max funds in the Dorm category. I've created a few more subforms for Codes that have a max limit. I've attached a view of the forms as they are arranged.

    The subfrmMaxLifetimeDriversEd is working, until the subfrmFunds is updated. Then I have to go out of the screen/form and come back in to force subfrmMaxLifetimeDriversEd to requery/reload. My goal is that when the Amount field on subfrmFunds (form on left bottom) updates, I want subfrmMaxLifeTimeDriversEd (subfrm on right bottom) to requery/reload.

    Thanks, again, for your input.
    Attached Thumbnails Attached Thumbnails Funds.PNG  

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    if you are in subform1 and want to requery subform2 you would use

    parent.subform2.requery

    this will either go in your field afterupdate event or perhaps the subform's afterupdate event

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have to refer to the SUBFORM control name, not the subform name itself. ACCESS usually names the control the same as the object name.
    So, if you have not renamed the subform control, in the after update event of the control "Amount" on the subform "subfrmFunds" you might try:

    (Forms!MainFormName.subformName.Requery)
    Code:
    Forms!frmYouthInfo.subfrmMaxLifetimeDriversEd.Requery

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

Similar Threads

  1. Replies: 5
    Last Post: 05-23-2016, 09:15 AM
  2. Replies: 1
    Last Post: 02-27-2014, 01:57 PM
  3. Replies: 1
    Last Post: 11-18-2012, 06:24 PM
  4. Form Field value updates
    By l2extasy in forum Forms
    Replies: 2
    Last Post: 07-10-2012, 09:21 AM
  5. Replies: 4
    Last Post: 12-01-2010, 01:12 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