How do I update textbox on Mainform on close of dialog window?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mashman
    New Member
    • Dec 2013
    • 4

    How do I update textbox on Mainform on close of dialog window?

    I am building in Access 2013

    I am using Navigation forms.

    My main forms is frm_orders
    - It has the field (bound) txtOrderTotal

    My subform is frm_orderdetail s
    - It has the (unbound) field txtSubTotal

    My dialog form to add items to order details is frm_AddItem
    - It has cboProduct, txtUnitPrice, txtQty

    Currently working - When I add a new item in my popup form and save it adds the item to the subform and changes the txtSubTotal

    What I can't seem to do on close of the frm_AddItem is take the txtSubTotal from the subform and place it in txtOrderTotal on the main form.

    I've tried accessing the text box via normal method Forms!frm_order !txtOrderTotal and Me.txtOrderTota l but vba just throughs a wobbly saying it can't find the field.

    Is it because I am using Navigation forms.

    [imgnothumb]http://bytes.com/attachment.php? attachmentid=74 44[/imgnothumb]
    Attached Files
    Last edited by zmbd; Jan 15 '14, 03:43 PM. Reason: [z{inserted image inline}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    1) Why?
    2) show the formula/code you are using. Please format using the [Code/] button.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      I suspect you need to tell it to requery.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Neo is more than likely correct; however, the navigation control has an unusual property and we need to see the refering formula/code.

        If OP will search on ZMBD and "Navigation Control" I've covered this before... http://bytes.com/topic/access/answer...ntrol-subforms I've made two such posts that cover the basics of using the Navigation Control.

        Comment

        • mashman
          New Member
          • Dec 2013
          • 4

          #5
          I was planning on having a Total field in the Orders Table so I could call upon it throughout the database which is why I wanted to populate that field from the field in the subform.

          I have decided to get rid of the Total field and I will instead calculate the total as and when I need it by adding line items in order details table as and when I need it.

          I am finding Navigation forms frustrating at times as searching around on the web mainly produces non navigation form coding which doesn't work.

          I have added your link to my delicious links thanks zmbd, and did the same for the other post you helped me with here on nav forms http://bytes.com/topic/access/answer...ba#post3763553

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            ah... something just occured to me...
            the new tempvar available to ACC2010
            [http://msdn.microsoft.com/en-us/libr....aspx]tempvars object [/url]

            I've only been playing with these for a very short while. The object stays stable until you remove it or the session closes, can be used in a query, and is one of the very few objects that both the Macro and VBA can both workwith.
            Here's a thread that goes over modifiying an exsisting code to to work with it... really straight forward: http://bytes.com/topic/access/answer...on#post3761896

            What I see here, to avoid the nasty navigationsubfo rm reference is to create the variable and from the subform store your value there and the set the controlsource of your unbound textbox to the tempvar...


            and Thank You (^_^)!

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #7
              I believe TempVars persist beyond the closing of the session. They are available for the life of the Access Application they are set in, or at least until the database is closed.

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                Temporary Variables are Global and will remain in memory until the Database is closed which is why Temporary Variables should be removed when you are finished using them (RemoveTempVar for individual removal/RemoveAllTempVa rs collectively).

                Comment

                • zmbd
                  Recognized Expert Moderator Expert
                  • Mar 2012
                  • 5501

                  #9
                  I may have the wrong term here.
                  In my mind for Access a session starts when the user opens the application and ends when the user closes the application.
                  I was not aware that the object would persist if the database was closed and the Access program remained open. I'll check that out in a momement.

                  Comment

                  • zmbd
                    Recognized Expert Moderator Expert
                    • Mar 2012
                    • 5501

                    #10
                    (although not best practice)

                    I set up a series of tempvars.* within a database application.
                    Obviously, closing the Access Program removed the object; however, so did closing the database front end and the all-in-one database.
                    At no time did I clear the tempvars collection via code, and I state again, if you open it close it, if you set it clear it (^_^).

                    Thus, I stand by my concept of a session being the point at which the database application is opened to the point it is closed by the end user.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32633

                      #11
                      For me, a session is a code session.

                      Access can open an application window.
                      In the Access window you can have multiple databases open for direct interaction with the user, but only ever one at a time.
                      Once a database is open there is a code context, or session, that is maintained until it is stopped or reset. After that it can be restarted.

                      Sessions are stopped whenever code is cancelled after a bug or the Reset button (in the VBA IDE) is pressed.

                      I believe TempVars persist for an open database. Beyond such sessions, but not after the database is closed.

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #12
                        We may have to have some sort of new word for the tempvars object. (^_^)

                        I have not tried the to use these between two different frontends/databases opened thru the same instance of the Access application. I suspect though that the scope is within the frontend/database-file that created the collection.

                        What I do know, is that they persist within a given frontend/database until that database is closed or they are explicitly cleared; they do not clear if there is an error (unlike global variables); and they may be an option for OP to workaround the cumbersome subcontrol references within the acc2010:navigat ion control.

                        Comment

                        Working...