Subform refresh and query view.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #16
    Originally posted by Rotorian
    Okay, I reread your insight again. The part that I am missing is where within the code does the information reside?
    What information are you talking about?

    PS. You've chopped off the first lines of your module. Your code starts in the middle of a procedure.

    Comment

    • Rotorian
      New Member
      • Sep 2009
      • 23

      #17
      I am looking for the "control" of the subform. As far as the code, that is all there is, well except for this;

      Code:
      Option Compare Database
      
      Private Sub addrecord_Click()
      Which is just above;

      Code:
      # On Error GoTo Err_addrecord_Click
      #  
      #     DoCmd.GoToRecord , , acNewRec

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #18
        Originally posted by Rotorian
        I am looking for the "control" of the subform.
        The SubForm IS a control.

        It looks like the name of your SubForm control may be [historyrequest subform]. It's hard to be sure from the code if you've used spaces in your names. It's best to look at the design of the form to find the name of the control. Open the Properties Pane (Alt-Enter) and look at the name when you select the control.

        Comment

        • Rotorian
          New Member
          • Sep 2009
          • 23

          #19
          Okay, I deleted the subform and started from scratch. In the form "tolog" I created a subform using the wizard. I asked the wizard to use query "historyrequest " to populate the subform. The query gets the records for the past 24hrs from table "tolog" to display in the subform. When doing Alt+Enter with the subform selected, the name is "historyrequest subform" this is also the name I gave it in the wizard. Now I went to "tologentry " which is the form used to input records into "tolog" table. In the OnClose event for the form I inserted the following;

          Code:
          Option Compare Database
          
          Private Sub Form_Close()
          
              historyrequestsubform.Form.Requery
          
          End Sub
          Should this not refresh the subform?

          I am getting the following error;

          Run-time error '424':
          Object Required

          When I select debug and the code window emerges, the historyrequests ubform.Form.Req uery is highlighted with an arrow pointing to it.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32656

            #20
            You could try Me.historyreque stsubform.Form. Requery.

            Unfortunately, IntelliSense won't easily show that it's recognized as you use all lower case. In truth, I suspect the name is wrong.

            Comment

            • Rotorian
              New Member
              • Sep 2009
              • 23

              #21
              Okay, I tried the above and did not work. Since I may have had some naming issues, I deleted the whole project (it was small so no worry there) and started again. Now, I recreated the tables and forms and inside of "FormToLog" is "SubFormShowPas tDay" which displays past 24hr records using "QueryPastD ay".

              Also in "FormToLog" I have a button, this button calls up "FormNewLogEntr y" from this form records are added to "TableLogEntrie s". In the OnClose event of "FormNewLogEntr y" I inserted the following code;

              Code:
              Private Sub Form_Close()
                  Me.SubFormShowPastDay.Form.Requery
              End Sub
              When I close "FormNewLogEntr y" I get the error

              "Compile Error: Method or data member not found"

              when the VB window is opened after choosing "Debug" .SubFormShowPas tDay is highlited in blue, not the usual yellow.

              If I open "FormToLog" in design view, and choose "SubFormShowPas tDay" (I.e. it has the edit form highlight) and do Alt+Enter in the subsequent window titled "Subform/Subreport: SubFormShowPast Day" under Data tab in the field Source Object "SubFormShowPas tDay" is displayed. Under the Other tab in the field Name "SubFormShowPas tDay" is displayed. So, am I correct the subform control is "SubFormShowPas tDay" ?

              If I remove "Me." from the above code, then the following error is displayed;

              "Run-timer error '424': Object required"

              Upon selecting Debug the VB window displays the event with the line "SubFormShowPas tDay.Form.Reque ry" highlighted in yellow with a yellow arrow pointing to it.

              I dont know what other information to give to help solve the problem or pinpoint my error :(. I may just have to create a button to refresh "FormToLog" for the user to refresh the records display in "SubFormShowPas tDay"

              All help appreciated..." Help me ObeeWan, You're my only hope" :)

              Regards,

              Comment

              • ChipR
                Recognized Expert Top Contributor
                • Jul 2008
                • 1289

                #22
                If this code is in the form named FormNewLogEntry , then that form doesn't have a SubFormShowPast Day, since it is actually on the form named FormToLog. You would need:
                Code:
                Forms![FormToLog]![SubFormShowPastDay].Form.Requery

                Comment

                • ChipR
                  Recognized Expert Top Contributor
                  • Jul 2008
                  • 1289

                  #23
                  Originally posted by ChipR
                  If this code is in the form named FormNewLogEntry , then that form doesn't have a SubFormShowPast Day, since it is actually on the form named FormToLog. You would need:
                  Code:
                  Forms![FormToLog]![SubFormShowPastDay].Form.Requery
                  Note that it is a good idea to check that the form you want to reference is open before you go and try to use it. To prevent errors, you can do something like:
                  Code:
                  If CurrentProject.AllForms("FormToLog").IsLoaded Then
                    'Do your stuff
                  End If
                  Last edited by NeoPa; Oct 25 '09, 10:44 PM. Reason: Added quote to include both posts

                  Comment

                  • Rotorian
                    New Member
                    • Sep 2009
                    • 23

                    #24
                    OMG!

                    ChipR for the win.

                    That was the Michael Jordan shot.

                    May your life be blessed with the fruit of Laurelin.

                    Thanks everyone for the help. What a great place.

                    Now if I may ask, with that code you are actually pointing the requery to go to the subform in "FormToLog" , where as with the previous code it was assuming that the subform was within "FormNewLogEntr y"?

                    I just want to edumacate myself, if possible, not just plug in a code and "voila" it works.

                    Again, thank you all for everything. Hope not to bug you too much again.

                    Regards,

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32656

                      #25
                      I haven't the time to check through the logic of this now, but I think you can assume Chip has the solution for you. He's pretty sound.

                      If you still experience problems then let us know. I'll check back later when I have a little more time.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32656

                        #26
                        Sorry, didn't catch this earlier.
                        Originally posted by Rotorian
                        Now if I may ask, with that code you are actually pointing the requery to go to the subform in "FormToLog" , where as with the previous code it was assuming that the subform was within "FormNewLogEntr y"?
                        Absolutely.

                        PS. You're welcome to post your queries in future. That's what we're here for :)

                        Comment

                        • ChipR
                          Recognized Expert Top Contributor
                          • Jul 2008
                          • 1289

                          #27
                          If you're patient, and it seems you are, you should find this link very useful:
                          Access Object Model Reference.

                          Comment

                          • Rotorian
                            New Member
                            • Sep 2009
                            • 23

                            #28
                            Bookmarked for usage. Again, thank you.

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32656

                              #29
                              Originally posted by ChipR
                              If you're patient, and it seems you are, you should find this link very useful:
                              Access Object Model Reference.
                              Me too. That's going into my Bytes database :)

                              Comment

                              Working...