locked
How to requery a subform from another subform on the same Main form? RRS feed

  • Question

  • have have two subforms on a Main form.  I want to enter data in to a text box on subform 1 and have subform 2 requery to show the update.  It's not happening!!!!  I have tried [Forms]![Main Frm]![Subform 2].Requery and no go.  I know this works if I'm on my Main form, but from subform to to subform is no go.  What am I doing wrong?
    Saturday, June 16, 2012 1:11 AM

Answers

  • If you are sure about the form names you are using, then my gut is thinking that it is maybe due to the fact that your entry hasn't been commited and thus the requery doesn't work as planned (it is working, just not as you expect).  So before the requery throw in

    If Me.Dirty = True the Me.Dirty = False
    [Forms]![Main Frm]![Subform 2].Requery

    Basically, force a save of your latest subform entry prior to requerying the other subform.


    Daniel Pineault, 2010 Microsoft MVP
    http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Proposed as answer by KCDW Saturday, June 16, 2012 3:01 AM
    • Marked as answer by Dummy yoyo Wednesday, June 27, 2012 7:33 AM
    Saturday, June 16, 2012 1:28 AM

All replies

  • If you are sure about the form names you are using, then my gut is thinking that it is maybe due to the fact that your entry hasn't been commited and thus the requery doesn't work as planned (it is working, just not as you expect).  So before the requery throw in

    If Me.Dirty = True the Me.Dirty = False
    [Forms]![Main Frm]![Subform 2].Requery

    Basically, force a save of your latest subform entry prior to requerying the other subform.


    Daniel Pineault, 2010 Microsoft MVP
    http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Proposed as answer by KCDW Saturday, June 16, 2012 3:01 AM
    • Marked as answer by Dummy yoyo Wednesday, June 27, 2012 7:33 AM
    Saturday, June 16, 2012 1:28 AM
  • Thanks Daniel.  I just noticed something while I was playing around with my form.  When I make a change to the field in my subform 1, I see subform 2 data kinda flicker like it is being requeryed but the data isn't changing.  I'll try your suggestion first, then go from there!

    Thank you

    FYI:  Your above suggestion worked.  Can you explain what exactly that does?  I'm trying to learn what's going on here!!!

    THanks again


    Saturday, June 16, 2012 1:45 AM
  • Hi Kevin,

    The Code is a true method of saving a record when the record is not saved by the database automatically.

    If Me.Dirty = True then Me.Dirty = False

    If the record is changed then save it.

    As Daniel said it commits the data to record


    Chris Ward


    • Edited by KCDW Saturday, June 16, 2012 3:10 AM add text
    Saturday, June 16, 2012 3:01 AM