Results 1 to 15 of 15
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Trying to requery a form

    I'm making a training database. In order to add students to a class, I made a form with 2 subforms. The main form [frmClassScheduleEnterNames] has two subforms that are not linked. [frmStudentListDeptSubF] has the student names, [frmTrainingRosterDeptSubF] is where the names are put into. I have the macro set to double click the names on [frmStudentListDeptSubF] and it [frmTrainingRosterDeptSubF]. It is filled with an append query. I can't get [frmTrainingRosterDeptSubF] to automatically requery after the double click. I'm sure it's possible, I just don't know how. Any help?

  2. #2
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Click image for larger version. 

Name:	macro.jpg 
Views:	19 
Size:	34.6 KB 
ID:	30127
    Here's the current macro

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The Add New Action dropdown should list Requery. Then drill to the subform.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I've tried to add a requery to it. It didn't work. Drill to the subform?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What exactly did you try? The Requery action has an argument, the control to be requeried. You can drill down to the subform you want to apply it to.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I'm sure I did it wrong. I keep getting an error.
    Click image for larger version. 

Name:	macro.jpg 
Views:	14 
Size:	41.6 KB 
ID:	30131
    Click image for larger version. 

Name:	macroerror.jpg 
Views:	14 
Size:	28.5 KB 
ID:	30132

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Apparently in a macro you just want the name of the subform, so try just frmTrainingRosterDeptSubF.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    That didn't work either
    Click image for larger version. 

Name:	macroerror.jpg 
Views:	13 
Size:	21.5 KB 
ID:	30133

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Worked for me in a brief test. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I would if the information wasn't real information

  11. #11
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I have a button to requery on the form I need to requery and it works with no problems. Is there a way to make my macro use that button automatically after I double click the name on the other form?

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You should be able to copy the action to this macro. Or switch to VBA and have more flexibility.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I'm going to be learning VBA soon. I have been told that it takes a while to understand. In the mean time, I'll do some macros. How would I copy the action into the macro?

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Copy was probably the wrong word. I meant to choose the same action(s) and argument(s) that perform what you want. You can also play with the convert macro to VBA function to start learning VBA.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    For vba, you'll need to learn how to reference a subform on a form. If I recall, for a control, it's
    [Forms]![Main form name]![subform control name].[Form]![control name on subform]
    To requery a subform, you don't have to go as deep:
    [Forms]![Main form name]![subform control name].[Form].Requery

    NOTE - [subform control name] is NOT the subform name. It is the control on the main form that contains the subform. Nor should it have the same name as your subform.
    You should be able to requery the sub form using your main form button click event with the syntax I posted.
    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. AfterUpdate requery does not requery list box
    By ittechguy in forum Programming
    Replies: 5
    Last Post: 09-05-2017, 08:51 AM
  2. Replies: 11
    Last Post: 04-09-2016, 08:54 PM
  3. Replies: 7
    Last Post: 07-01-2015, 10:29 AM
  4. Replies: 3
    Last Post: 08-26-2014, 12:52 PM
  5. Replies: 1
    Last Post: 05-26-2014, 10:31 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