Results 1 to 11 of 11
  1. #1
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149

    problem to show data in subform

    I have a subform "ItemForm" in a mainform, and a button to call another form "DataForm" to capture some data.
    when return from DataForm, I want the ItemForm refresh as some data is entered in DataForm.


    But the below does not show any data in ItemForm.
    Code:
        DoCmd.OpenForm "DataForm", , , , , acDialog, 5
        Me.ItemForm.Requery
        Me.Refresh

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    ItemForm is name of subform container control?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Use this syntax, where subFormControlName is the name of your subform control, not your subform:

    Me.subformControlName.Form.Requery

    or learn this one so that you can requery any subform from any other form

    Forms!FormNameHere.subformControlName.Form.Requery

    That assumes you have no spaces or special characters in any of your object names (except possibly underscore), which should be the case.
    Last edited by Micron; 01-18-2022 at 09:57 AM. Reason: code correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Using .Form is not necessary. If it is used, focus will be moved to first record of subform.
    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.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    That's easy enough to prevent by using Bookmark property.
    EDIT - in fact, IIRC, any method of requerying of a subform will do that?
    Even a requery of a continuous form or datasheet will do that even if it's not a subform.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    If not referencing a subform, then .Form is not relevant and any Requery of a stand-alone form will move focus to first record.

    Point is, use of .Form is not required for subform requery so something else must be issue in OP's situation.

    uoghk, if you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    If not referencing a subform,
    why would you think this doesn't apply to a subform situation, given the first post title (that formatting is a result of copy/paste, not me)?
    problem to show data in subform

    I want the ItemForm refresh as some data is entered in DataForm.
    "ItemForm" is a subform
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    @Micron, I did not say does not apply to subform situation. I said "If not referencing a subform" meaning if the path reference is to a stand-alone form, then .Form certainly is not relevant and Requery action will move focus to first record. I was responding to your comment "Even a requery of a continuous form or datasheet will do that even if it's not a subform."

    I know the OP is asking about a subform. That's why I said .Form in path reference is not necessary but that if it is included then focus will move to first record of subform. The subform will requery just fine without .Form.
    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.

  9. #9
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    Thanks Micron. You are right.
    I change the syntax to Me.subformControlName.Form.Requery then it works.

    Also thanks to June7.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Well, I did testing and it works for me without .Form.

    But I do name container control different from the form it holds, like ctrDetail.
    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.

  11. #11
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    IMO, you cannot go wrong with that syntax if you understand the hierarchy of your forms (navigation forms not included) regardless of whatever may or may not work.
    It should work in all situations, regardless of how you name your subform control. Access upgrades have a way of breaking things that work for years but were never quite kosher.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 10-18-2017, 09:36 AM
  2. SQL Server Data won't show up in subform
    By Paul H in forum Forms
    Replies: 4
    Last Post: 08-08-2016, 01:15 PM
  3. Replies: 2
    Last Post: 08-05-2016, 09:47 AM
  4. Replies: 2
    Last Post: 09-27-2014, 09:48 AM
  5. Subform will not show data
    By Brian62 in forum Forms
    Replies: 2
    Last Post: 02-19-2010, 10:43 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