Requery Subform

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SBC News Groups

    #1

    Requery Subform

    I have a form that the user enters some information on and then clicks a
    button to save the record. I do with the following line:

    DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Once this line executes, I have a sub form that I want to "refresh" because
    the newly saved information should now display on the sub form. I am trying
    to do this with this line:

    Forms![sub-frmRegistered_B idders].Requery

    Nut I get and error message telling me that Access can not find the form
    "sub-frmRegistered_B idders".

    So my question is this, how do I refresh the sub form after the information
    is stored?

    Thanks,

    Mike


  • Allen Browne

    #2
    Re: Requery Subform

    Subforms are not open in their own right, so they are not part of the Forms
    collection.

    You need:
    Forms![NameOfYourMainF ormHere].[sub-frmRegistered_B idders].Form.Requery

    Explanation:
    Referring to Controls on a Subform
    at:
    How to refer to controls in a subform in a Microsoft Access database.


    Other suggestions
    =============
    a) If the above doesn't work, the Name of the subform control could be
    different than the name of the form loaded into it (its Source Object.)

    b) You may find it easier to save the form with:
    RunCommand acCmdSaveRecord
    or even:
    If Me.Dirty Then Me.Dirty = False

    c) If you have a main form and subform both bound to the same table, and the
    table has an AutoNumber primary key, watch out for this bug:
    Fixing AutoNumbers when Access assigns negatives or duplicates
    at:
    Identifies why Microsoft Access assigns duplicate AutoNumbers or wildly inappropriate values for AutoNumbers, and explains how to correct a database that already has these problems.


    --
    Allen Browne - Microsoft MVP. Perth, Western Australia
    Reply to group, rather than allenbrowne at mvps dot org.

    "SBC News Groups" <me@you.netwrot e in message
    news:7Gw6h.2547 3$TV3.24021@new ssvr21.news.pro digy.com...
    >I have a form that the user enters some information on and then clicks a
    >button to save the record. I do with the following line:
    >
    DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    >
    Once this line executes, I have a sub form that I want to "refresh"
    because the newly saved information should now display on the sub form. I
    am trying to do this with this line:
    >
    Forms![sub-frmRegistered_B idders].Requery
    >
    Nut I get and error message telling me that Access can not find the form
    "sub-frmRegistered_B idders".
    >
    So my question is this, how do I refresh the sub form after the
    information is stored?

    Comment

    • SBC News Groups

      #3
      Re: Requery Subform

      Thansk for the replay Allen, but I still can not get it to work. I modified
      my line to the following:

      Forms![frmBidders].[sub-frmRegistered_B idders].Form.Requery

      With a period between the [frmBidders] and [sub-frmRegistered_B idders] I get
      an error saying Access can't find the field "|" referred to in your
      expression.

      If I cahnge the the . to a ! I receive a run-time error 2465, Access can't
      find the field 'sub-frmRegistered_B idders' referred to in your expression.

      I dont understand your other suggestions a or b and the form and sub form
      are not bound to the same table. The sub form is bound to a query and the
      form is bound to a table.

      What I am doing wrong? Can you help me?

      Mike


      "Allen Browne" <AllenBrowne@Se eSig.invalidwro te in message
      news:455ad7ef$0 $28169$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
      Subforms are not open in their own right, so they are not part of the
      Forms collection.
      >
      You need:
      Forms![NameOfYourMainF ormHere].[sub-frmRegistered_B idders].Form.Requery
      >
      Explanation:
      Referring to Controls on a Subform
      at:
      How to refer to controls in a subform in a Microsoft Access database.

      >
      Other suggestions
      =============
      a) If the above doesn't work, the Name of the subform control could be
      different than the name of the form loaded into it (its Source Object.)
      >
      b) You may find it easier to save the form with:
      RunCommand acCmdSaveRecord
      or even:
      If Me.Dirty Then Me.Dirty = False
      >
      c) If you have a main form and subform both bound to the same table, and
      the table has an AutoNumber primary key, watch out for this bug:
      Fixing AutoNumbers when Access assigns negatives or duplicates
      at:
      Identifies why Microsoft Access assigns duplicate AutoNumbers or wildly inappropriate values for AutoNumbers, and explains how to correct a database that already has these problems.

      >
      --
      Allen Browne - Microsoft MVP. Perth, Western Australia
      Reply to group, rather than allenbrowne at mvps dot org.
      >
      "SBC News Groups" <me@you.netwrot e in message
      news:7Gw6h.2547 3$TV3.24021@new ssvr21.news.pro digy.com...
      >>I have a form that the user enters some information on and then clicks a
      >>button to save the record. I do with the following line:
      >>
      >DoCmd.DoMenuIt em acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
      >>
      >Once this line executes, I have a sub form that I want to "refresh"
      >because the newly saved information should now display on the sub form. I
      >am trying to do this with this line:
      >>
      >Forms![sub-frmRegistered_B idders].Requery
      >>
      >Nut I get and error message telling me that Access can not find the form
      >"sub-frmRegistered_B idders".
      >>
      >So my question is this, how do I refresh the sub form after the
      >information is stored?
      >
      >

      Comment

      • Lyle Fairfield

        #4
        Re: Requery Subform

        If the subform has a module, or has the HasModule property set to true
        then

        Form_sub-frmRegistered_B idder.Requery

        should do the trick.

        On Nov 14, 11:26 pm, "SBC News Groups" <m...@you.netwr ote:
        I have a form that the user enters some information on and then clicks a
        button to save the record. I do with the following line:
        >
        DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        >
        Once this line executes, I have a sub form that I want to "refresh" because
        the newly saved information should now display on the sub form. I am trying
        to do this with this line:
        >
        Forms![sub-frmRegistered_B idders].Requery
        >
        Nut I get and error message telling me that Access can not find the form
        "sub-frmRegistered_B idders".
        >
        So my question is this, how do I refresh the sub form after the information
        is stored?
        >
        Thanks,
        >
        Mike

        Comment

        • SBC News Groups

          #5
          Re: Requery Subform

          The Has Module property is set to No.

          Any other ideas?

          Mike

          "Lyle Fairfield" <lylefairfield@ aim.comwrote in message
          news:1163648148 .432007.19780@h 48g2000cwc.goog legroups.com...
          If the subform has a module, or has the HasModule property set to true
          then
          >
          Form_sub-frmRegistered_B idder.Requery
          >
          should do the trick.
          >
          On Nov 14, 11:26 pm, "SBC News Groups" <m...@you.netwr ote:
          >I have a form that the user enters some information on and then clicks a
          >button to save the record. I do with the following line:
          >>
          >DoCmd.DoMenuIt em acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
          >>
          >Once this line executes, I have a sub form that I want to "refresh"
          >because
          >the newly saved information should now display on the sub form. I am
          >trying
          >to do this with this line:
          >>
          >Forms![sub-frmRegistered_B idders].Requery
          >>
          >Nut I get and error message telling me that Access can not find the form
          >"sub-frmRegistered_B idders".
          >>
          >So my question is this, how do I refresh the sub form after the
          >information
          >is stored?
          >>
          >Thanks,
          >>
          >Mike
          >

          Comment

          • Allen Browne

            #6
            Re: Requery Subform

            Open the main form in design view.

            Right-click the edge of the subform control, and choose Properties.

            What is the Name property of the subform control?
            (It's the first item on the Other tab of the Properties box.)

            The Name of the subform control may not be sub-frmRegistered_B idders, even
            if that is the name of the form that gets loaded into the control.

            --
            Allen Browne - Microsoft MVP. Perth, Western Australia
            Tips for Access users - http://allenbrowne.com/tips.html
            Reply to group, rather than allenbrowne at mvps dot org.

            "SBC News Groups" <me@you.netwrot e in message
            news:rrQ6h.3048 $yE6.834@newssv r14.news.prodig y.com...
            Thansk for the replay Allen, but I still can not get it to work. I
            modified my line to the following:
            >
            Forms![frmBidders].[sub-frmRegistered_B idders].Form.Requery
            >
            With a period between the [frmBidders] and [sub-frmRegistered_B idders] I
            get an error saying Access can't find the field "|" referred to in your
            expression.
            >
            If I cahnge the the . to a ! I receive a run-time error 2465, Access can't
            find the field 'sub-frmRegistered_B idders' referred to in your expression.
            >
            I dont understand your other suggestions a or b and the form and sub form
            are not bound to the same table. The sub form is bound to a query and the
            form is bound to a table.
            >
            What I am doing wrong? Can you help me?
            >
            Mike
            >
            >
            "Allen Browne" <AllenBrowne@Se eSig.invalidwro te in message
            news:455ad7ef$0 $28169$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
            >Subforms are not open in their own right, so they are not part of the
            >Forms collection.
            >>
            >You need:
            >>
            >Forms![NameOfYourMainF ormHere].[sub-frmRegistered_B idders].Form.Requery
            >>
            >Explanation:
            > Referring to Controls on a Subform
            >at:
            > http://allenbrowne.com/casu-04.html
            >>
            >Other suggestions
            >============ =
            >a) If the above doesn't work, the Name of the subform control could be
            >different than the name of the form loaded into it (its Source Object.)
            >>
            >b) You may find it easier to save the form with:
            > RunCommand acCmdSaveRecord
            >or even:
            > If Me.Dirty Then Me.Dirty = False
            >>
            >c) If you have a main form and subform both bound to the same table, and
            >the table has an AutoNumber primary key, watch out for this bug:
            > Fixing AutoNumbers when Access assigns negatives or duplicates
            >at:
            > http://allenbrowne.com/ser-40.html
            >>
            >"SBC News Groups" <me@you.netwrot e in message
            >news:7Gw6h.254 73$TV3.24021@ne wssvr21.news.pr odigy.com...
            >>>I have a form that the user enters some information on and then clicks a
            >>>button to save the record. I do with the following line:
            >>>
            >>DoCmd.DoMenuI tem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
            >>>
            >>Once this line executes, I have a sub form that I want to "refresh"
            >>because the newly saved information should now display on the sub form.
            >>I am trying to do this with this line:
            >>>
            >>Forms![sub-frmRegistered_B idders].Requery
            >>>
            >>Nut I get and error message telling me that Access can not find the form
            >>"sub-frmRegistered_B idders".
            >>>
            >>So my question is this, how do I refresh the sub form after the
            >>information is stored?

            Comment

            • Wayne Gillespie

              #7
              Re: Requery Subform

              On Thu, 16 Nov 2006 03:46:25 GMT, "SBC News Groups" <me@you.netwrot e:

              Set it to Yes.
              >The Has Module property is set to No.
              >
              >Any other ideas?
              >
              >Mike
              >
              >"Lyle Fairfield" <lylefairfield@ aim.comwrote in message
              >news:116364814 8.432007.19780@ h48g2000cwc.goo glegroups.com.. .
              >If the subform has a module, or has the HasModule property set to true
              >then
              >>
              >Form_sub-frmRegistered_B idder.Requery
              >>
              >should do the trick.
              >>
              >On Nov 14, 11:26 pm, "SBC News Groups" <m...@you.netwr ote:
              >>I have a form that the user enters some information on and then clicks a
              >>button to save the record. I do with the following line:
              >>>
              >>DoCmd.DoMenuI tem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
              >>>
              >>Once this line executes, I have a sub form that I want to "refresh"
              >>because
              >>the newly saved information should now display on the sub form. I am
              >>trying
              >>to do this with this line:
              >>>
              >>Forms![sub-frmRegistered_B idders].Requery
              >>>
              >>Nut I get and error message telling me that Access can not find the form
              >>"sub-frmRegistered_B idders".
              >>>
              >>So my question is this, how do I refresh the sub form after the
              >>information
              >>is stored?
              >>>
              >>Thanks,
              >>>
              >>Mike
              >>
              >
              Wayne Gillespie
              Gosford NSW Australia

              Comment

              • SBC News Groups

                #8
                Re: Requery Subform

                Thanks a bunch!!

                The name was actually qryRegistered_B idders not sub-frmRegistered_B idders.

                It works now.

                Mike

                "Allen Browne" <AllenBrowne@Se eSig.invalidwro te in message
                news:455bf81f$0 $28221$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
                Open the main form in design view.
                >
                Right-click the edge of the subform control, and choose Properties.
                >
                What is the Name property of the subform control?
                (It's the first item on the Other tab of the Properties box.)
                >
                The Name of the subform control may not be sub-frmRegistered_B idders, even
                if that is the name of the form that gets loaded into the control.
                >
                --
                Allen Browne - Microsoft MVP. Perth, Western Australia
                Tips for Access users - http://allenbrowne.com/tips.html
                Reply to group, rather than allenbrowne at mvps dot org.
                >
                "SBC News Groups" <me@you.netwrot e in message
                news:rrQ6h.3048 $yE6.834@newssv r14.news.prodig y.com...
                >Thansk for the replay Allen, but I still can not get it to work. I
                >modified my line to the following:
                >>
                >Forms![frmBidders].[sub-frmRegistered_B idders].Form.Requery
                >>
                >With a period between the [frmBidders] and [sub-frmRegistered_B idders] I
                >get an error saying Access can't find the field "|" referred to in your
                >expression.
                >>
                >If I cahnge the the . to a ! I receive a run-time error 2465, Access
                >can't find the field 'sub-frmRegistered_B idders' referred to in your
                >expression.
                >>
                >I dont understand your other suggestions a or b and the form and sub form
                >are not bound to the same table. The sub form is bound to a query and the
                >form is bound to a table.
                >>
                >What I am doing wrong? Can you help me?
                >>
                >Mike
                >>
                >>
                >"Allen Browne" <AllenBrowne@Se eSig.invalidwro te in message
                >news:455ad7ef$ 0$28169$5a62ac2 2@per-qv1-newsreader-01.iinet.net.au ...
                >>Subforms are not open in their own right, so they are not part of the
                >>Forms collection.
                >>>
                >>You need:
                >>>
                >>Forms![NameOfYourMainF ormHere].[sub-frmRegistered_B idders].Form.Requery
                >>>
                >>Explanation :
                >> Referring to Controls on a Subform
                >>at:
                >> http://allenbrowne.com/casu-04.html
                >>>
                >>Other suggestions
                >>=========== ==
                >>a) If the above doesn't work, the Name of the subform control could be
                >>different than the name of the form loaded into it (its Source Object.)
                >>>
                >>b) You may find it easier to save the form with:
                >> RunCommand acCmdSaveRecord
                >>or even:
                >> If Me.Dirty Then Me.Dirty = False
                >>>
                >>c) If you have a main form and subform both bound to the same table, and
                >>the table has an AutoNumber primary key, watch out for this bug:
                >> Fixing AutoNumbers when Access assigns negatives or duplicates
                >>at:
                >> http://allenbrowne.com/ser-40.html
                >>>
                >>"SBC News Groups" <me@you.netwrot e in message
                >>news:7Gw6h.25 473$TV3.24021@n ewssvr21.news.p rodigy.com...
                >>>>I have a form that the user enters some information on and then clicks a
                >>>>button to save the record. I do with the following line:
                >>>>
                >>>DoCmd.DoMenu Item acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
                >>>>
                >>>Once this line executes, I have a sub form that I want to "refresh"
                >>>because the newly saved information should now display on the sub form.
                >>>I am trying to do this with this line:
                >>>>
                >>>Forms![sub-frmRegistered_B idders].Requery
                >>>>
                >>>Nut I get and error message telling me that Access can not find the
                >>>form "sub-frmRegistered_B idders".
                >>>>
                >>>So my question is this, how do I refresh the sub form after the
                >>>informatio n is stored?
                >
                >

                Comment

                Working...