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

    Requery a subform

    I have a form [frmClassScheduleEnterNames]. It has two subforms [frmStudentListDeptSubF] & [frmTrainingRosterDeptSubF] I have my list of student in [frmStudentListDeptSubF] which populates the second subform [frmTrainingRosterDeptSubF] by using an append query. I want the subform [frmTrainingRosterDeptSubF] to immediately requery after the append happens. Any ideas that might help me?

  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
    If "frmTrainingRosterDeptSubF" is the name of the SubFormControl that displays the frmTrainingRosterDeptSubF then this will work:
    Forms!frmClassScheduleEnterNames.frmTrainingRoster DeptSubF.FORM.Requery

    http://access.mvps.org/access/forms/frm0031.htm

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I really hate asking this. Where do I enter that?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    In the same procedure running the append query. Are you using VBA? Post the procedure code.

    RuralGuy, do you notice the space in your suggested code between Roster and Dept? How did that happen? Randomly thrown in by the forum?
    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
    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
    Quote Originally Posted by June7 View Post
    RuralGuy, do you notice the space in your suggested code between Roster and Dept? How did that happen? Randomly thrown in by the forum?
    June, the space is a bug in the bulletin board display software. It's been there for many versions.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Yes, I've noticed it for quite some time. Annoying.

    So, UT227, beware of copy/paste.
    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
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Thanks. I will note that.
    As for the append query, I have not learned VBA yet. It's on my to do list. So, when you say it's on the same procedure as the append query, are you talking about entering it in the code for VBA? You want a pic of my append query?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Don't need a pic, the SQL text pasted into post would be sufficient. Open query object in SQLView and copy/paste.

    Yes, VBA procedure.

    Exactly how are you executing the append query? Manually from the Navigation pane?
    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
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    This is the SQL for the append query:
    INSERT INTO tblTrainingRoster ( EmployeesID, ScheduleID, ClassID, TCOLEClassListID, InHouseClassListID, ClassTypesID, DOT, DOTEnd, hrs, [Grant] )
    SELECT tblEmployees.EmployeesID, tblTrainingSchedule.ScheduleID, tblTrainingSchedule.ClassID, tblTrainingSchedule.TCOLEClassListID, tblTrainingSchedule.InHouseClassListID, tblTrainingSchedule.ClassTypesID, tblTrainingSchedule.DOT, tblTrainingSchedule.DOTEnd, tblTrainingSchedule.Hours, tblTrainingSchedule.Grant
    FROM tblEmployees, tblTrainingSchedule
    WHERE (((tblEmployees.EmployeesID)=[Forms]![frmClassScheduleEnterNames]![frmStudentListDeptSubF]![EmployeesID]) AND ((tblTrainingSchedule.ScheduleID)=[Forms]![frmClassScheduleEnterNames]![ScheduleID]));

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    I would use VBA. The real trick is figuring out what event to put code into (button Click, form or control AfterUpdate, etc). Exact syntax for referencing controls depends on where the code is located. If it is behind [frmStudentListDeptSubF]:

    CurrentDb.Execute "INSERT INTO tblTrainingRoster (EmployeesID, ScheduleID, ClassID, TCOLEClassListID, InHouseClassListID, ClassTypesID, DOT, DOTEnd, hrs, [Grant]) " & _
    "SELECT " & Me.EmployeesID & " AS EID, ScheduleID, ClassID, TCOLEClassListID, InHouseClassListID, ClassTypesID, DOT, DOTEnd, Hours, Grant " & _
    "FROM tblTrainingSchedule WHERE ScheduleID=" & Me.Parent.ScheduleID

    Me.Parent.[frmTrainingRosterDeptSubF].Requery

    Or continue to use your manual method and refresh the form with the Refresh button from ribbon. Keep in mind 'the more user-friendly, the more code'.
    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.

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

Similar Threads

  1. Subform won't requery
    By Heathey94 in forum Access
    Replies: 36
    Last Post: 09-23-2016, 10:09 AM
  2. Subform Requery
    By MTSPEER in forum Programming
    Replies: 15
    Last Post: 04-29-2015, 09:14 AM
  3. requery subform
    By nswhit in forum Forms
    Replies: 2
    Last Post: 05-16-2013, 09:34 AM
  4. requery in subform
    By putte11 in forum Forms
    Replies: 7
    Last Post: 04-22-2013, 02:43 PM
  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