Results 1 to 5 of 5
  1. #1
    bxdobs is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2012
    Posts
    35

    Requery does not appear to work for a SubForm Query


    I have a DATASHEET Subform linked to a Query of a table I am making changes to. The Query takes data from the Table and embelishes the data based on the table content.

    If I add, edit or delete a record I need to requery the Datasheet Subform on the main form.

    Main form holds both the call to the Table Update Forms and the SubForm ... the issue is that after VBA returns from frmTable*, it doesn't appear to do the requery ... yet if I do left and right arrows it works fine

    Code:
    If strFnc = "Add" Then
       DoCmd.OpenForm ("frmTableAdd")    
       Me.frmMyQuerySubForm.Form.Requery
    ElseIf strFnc = "Edit" Then
       DoCmd.OpenForm ("frmTableEdit")    
       Me.frmMyQuerySubForm.Form.Requery
    ElseIf strFnc = "Del" Then
       DoCmd.OpenForm ("frmTableDelete")    
       Me.frmMyQuerySubForm.Form.Requery
    ElseIf strFnc = "LeftArrow" Then
        ginMonth = ginMonth - 1
        If ginMonth <= 0 Then
           ginMonth = 12
           ginYear = ginYear - 1
        End If
        Me.frmItemQuery.Form.Requery
    ElseIf strFnc = "RightArrow" Then
        ginMonth = ginMonth + 1
        If ginMonth >= 13 Then
           ginMonth = 1
           ginYear = ginYear + 1
        End If
        Me.frmItemQuery.Form.Requery   
    EndIf

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You realize that unless you open the form in dialog mode, the requery is executed as soon as the form opens.
    Last edited by pbaldy; 12-31-2012 at 10:23 AM. Reason: Fix spelling
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bxdobs is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2012
    Posts
    35
    Sorry I am not following your statement ... this code is on the main form which is in dialog mode ... depending on the value of strFnc a NEW form is opened which can ADD, EDIT or DELETE records from the table being Queried on the subform on the MAIN form.

    Consider that I have 3 records returned from the Query for Dec/2012 (filtered by month/year), if I open form frmTableDelete and delete the current record (one of the 3 records ... I don't actually delete records I just flag them as DELETED) then when the frmTableDelete form closes my expectation is that the Me.frmItemQuery.Form.Requery should fire and I should have 2 records ... this requery doesn't appear to do anything after the close of the Form.

    If I punch my spin button (left and or right arrow) going to Nov/2012 then returning to Dec/2012 the Me.frmItemQuery.Form.Requery works (showing the 2 expected records)


    Ok just ran a test ... the issue is with the requery line following the DoCmd.OpenForm ... it is running before the frmTableDelete Form is completed ... I was thinking in linear program mode (expecting requery would not run until the Opened Form was closed) ... the requery is being done ... just not on the modified data ... I need to wait for the form to close before the requery can be called.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by bxdobs View Post
    Ok just ran a test ... the issue is with the requery line following the DoCmd.OpenForm ... it is running before the frmTableDelete Form is completed ... I was thinking in linear program mode (expecting requery would not run until the Opened Form was closed) ... the requery is being done ... just not on the modified data ... I need to wait for the form to close before the requery can be called.
    This is what I was trying to tell you. Look at the arguments available in OpenForm, one of which will do what you want.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    bxdobs is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2012
    Posts
    35
    Thank-you ... as I stated ... I didn't follow your first reply ... your second reply led me to:

    Setting the frmTable* forms to POPUP and MODAL and calling them with

    Code:
     DoCmd.OpenForm "frmTableDel", acNormal, , , acFormPropertySettings, acDialog
    This solved the issue ... again ... appreciated your help.

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

Similar Threads

  1. Requery Main Form, Keep Focus on Subform
    By burrina in forum Forms
    Replies: 8
    Last Post: 11-21-2012, 03:50 AM
  2. Replies: 11
    Last Post: 09-17-2012, 02:23 PM
  3. Replies: 3
    Last Post: 04-17-2012, 10:28 AM
  4. Replies: 3
    Last Post: 10-10-2011, 06:33 PM
  5. Refresh Requery Subform
    By eww in forum Programming
    Replies: 1
    Last Post: 04-05-2011, 09:19 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