Results 1 to 7 of 7
  1. #1
    ecampos is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Posts
    9

    Subform will not requery

    I am trying to requery a subform from a command button on a main form. The two forms are not linked. The subform data source is a SQL query I am updating manually. After making the query update (which works correctly) - I have tried every combination of requery/refresh commands I can think of to make the subform display the new data.

    From the Parent form:
    Me!Subform.Form.Requery


    Me.Subform.Form.Requery
    Me.Subform.Requery

    I even tried putting a command button on the subform to execute Me.Requery

    None of these work. I can open the underlying SQL query and see that it has changed. But the subform will just not display the new data. It will refresh and display the correct data only if I close and reopen the form. Subform is a continuous form if that matters.

    Any idea what I could be missing?

    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,558
    Is Subform actually the subformcontrol name?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ecampos is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Posts
    9
    In my program I am using the actual name of the subform control

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    The subform data source is a SQL query I am updating manually.
    How are you doing this and how are you updating the record source of the subform?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    ecampos is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Posts
    9
    So I ended up getting this to work.

    Code:
    Me.Subform.Form.RecordSource = "QueryName"
    That forces the subform to requery and display the new data. So my problem is fixed. But I would still like to know why the Form.Requery command does not work from either the parent form or the child form - if anyone has any ideas.

  6. #6
    ecampos is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Posts
    9
    Quote Originally Posted by moke123 View Post
    How are you doing this and how are you updating the record source of the subform?
    I am setting the query definition like this:

    Code:
    Public Sub SetQuery(query_name As String, query_string As String)
        Application.CurrentDb.QueryDefs(query_name).SQL = query_string
    End Sub
    I was not otherwise changing or updating the record source of the subform. It's just set in the properties.

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    But I would still like to know why the Form.Requery command does not work from either the parent form or the child form - if anyone has any ideas.
    The form retains the original recordsource until it is changed would be my guess.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 1
    Last Post: 09-13-2022, 03:44 AM
  2. Replies: 2
    Last Post: 10-09-2021, 07:15 AM
  3. requery 1 subform after activity on another subform
    By markjkubicki in forum Programming
    Replies: 5
    Last Post: 10-24-2019, 03:29 PM
  4. Subform Requery
    By MTSPEER in forum Programming
    Replies: 15
    Last Post: 04-29-2015, 09:14 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