Results 1 to 7 of 7
  1. #1
    dweekley is offline Advanced Beginner
    Windows XP Access 2002 (version 10.0)
    Join Date
    May 2010
    Posts
    52

    Requery Control On Subform

    Having an issue formatting the Vb script to requery a control on a subform when closing a popup form.



    I have put the following in the Close Event of the popup form 'Operation_Service'. The order is closing 'Operation_Service' leaving the main form 'f_Estimate' and subform 'f_Estimate_Ops' open.

    Forms("f_Operation_Process").Controls("f_Estimate" ).Form.Controls("Estimate_Ops").Controls("Operatio n_Service").Requery

    TIA
    David

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    My first notion:
    Code:
    sub Form_close    'this code is in the popup
        Form_f_Estimate.f_Estimate_ops.[Operation n_Service].requery
        docmd.close acform,me.name
    f_estimate_ops should be the name of the control holding the subform. You should get some intellisense help when typing the first line...
    RuralGuy's advice is spot on when the main form and subform are trading amongst themselves. You case is activity from a 'foreign' form.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The link also includes using the Forms collection for referencing.
    I may be wrong here but I always thought it was not a good idea to use the "Form_" syntax in a reference.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Is the popup called by the subform or the main form?

    Open the popup in acDialog mode and this will suspend code execution in the calling form until the popup closes. So put the requery code in the calling form.

    ...
    DoCmd.OpenForm "formname", , , , , acDialog
    Me.controlname.Requery 'if OpenForm code and control are on same form
    ...

    Wait, just read OP again. I am confused. The popup and control are the same name? Why? What kind of control do you want to requery?
    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.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The posted expression seems to invoke too many control(s) and forms references. I've had trouble before with the bracketed syntax for referring to subform controls, so I don't use it. To drill down to a subform control, I always use this syntax
    [Forms]![Main form name]![subform control name].[Form]![control name on subform] where [subform control name] is the subform control and NOT the subform. Hopefully, you don't allow these to have the same name.

    To reference a property of same (e.g. record count), I found this always worked (whereas the former didn't for some reason)
    Forms("MainFormName").Controls("subformControlName ").Form.Recordset.Recordcount
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    dweekley is offline Advanced Beginner
    Windows XP Access 2002 (version 10.0)
    Join Date
    May 2010
    Posts
    52
    It did. Thank you much

    David

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

Similar Threads

  1. Replies: 5
    Last Post: 04-15-2015, 04:20 PM
  2. WebBrowser control requery
    By Historypaul in forum Forms
    Replies: 4
    Last Post: 11-12-2014, 09:09 PM
  3. requery subform in tab Control
    By raffi in forum Forms
    Replies: 2
    Last Post: 10-16-2014, 12:36 PM
  4. requery subform
    By nswhit in forum Forms
    Replies: 2
    Last Post: 05-16-2013, 09:34 AM
  5. Replies: 3
    Last Post: 04-17-2012, 10:28 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