Results 1 to 7 of 7
  1. #1
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87

    Requery Subform from combo box on Main Form

    I am working on a form that has a sub form and I'm having trouble getting the sub form to requery when i make a change to a combo box on the main form.

    Main Form = Wholesale Orders
    Sub Form = Wholesale Orders Subform

    When I make a change to the MdlYrID combo box on the main form, I would like the cascaded ModelID Combo box and two other text fields to requery.



    Code:
    Private Sub cboMdlYr_AfterUpdate()
    Me.Dirty = False
    End Sub


    Private Sub Form_AfterUpdate()
    Forms![Wholesale Orders].Form.[Wholesale Orders Subform].Requery
    End Sub

    The error I keep getting is Run-Time Error 2465
    Microsoft Access can't find the field '|1' referred to in your expression.

    Not sure what I'm missing. Thanks in advance.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Please try this:
    Code:
    Private Sub cboMdlYr_AfterUpdate()
    Me.Dirty = False
    Me.sfrmWholesaleOrdersSubform.Form.Requery  'sfrmWholesaleOrdersSubform is the name of the subform control on the Wholesale Orders form whose source object is Wholesale Orders Subform ; side note avoid spaces in field and objects name in Access
    End Sub
    No need for the Form_AfterUpdate code.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Vlad,

    Thank you for responding. I must still be missing something though.

    Private Sub cboMdlYr_AfterUpdate()
    Me.Dirty = False
    Me.WholesaleOrdersSubform.Form.Requery
    End Sub

    The above code is what I have for the combo box control on WholesaleOrders form. The name listed under the Other tab of the sub form is WholesaleOrdersSubform. If I make a change in the MdlYrID combo box on the main form it still doesn't reset the information in the sub form. The only way to change it is manually clicking on the RefreshAll button. I've attached the db. Not quite sure what I'm missing. Thanks in advance.
    Attached Files Attached Files

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Here you go. you want to requery the combo box not the subform.

    Cheers,
    Vlad
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    Ahh. I had tried that previously but had the requery statement in the form after update. To take it one step further, is there a way to 0 out the Allocation and Allocation_Used fields when the requery happens? Thank you.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Yes, just follow the same syntax to do it:, add these two rows to the code:

    Me.WholesaleOrdersSubform.Form.Controls("Allocatio n")=0
    Me.WholesaleOrdersSubform.Form.Controls("Allocation_Used")=0

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    Topflite66 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    87
    That'll work. Thank you very much for your help. Stay safe!!

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

Similar Threads

  1. Requery a subform form a combo box in a main form!
    By lewisoh in forum Database Design
    Replies: 2
    Last Post: 09-10-2015, 07:23 AM
  2. Requery subform from main form
    By nswhit in forum Forms
    Replies: 7
    Last Post: 05-13-2013, 02:22 PM
  3. Replies: 2
    Last Post: 01-11-2013, 06:51 PM
  4. Replies: 3
    Last Post: 04-17-2012, 10:28 AM
  5. Replies: 3
    Last Post: 10-10-2011, 06:33 PM

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