How to import data from one form to another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RWREBB
    New Member
    • Jun 2010
    • 4

    #1

    How to import data from one form to another form

    Can I do this using the expression builder from the textbox?
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    I'm going to give you a qualified "yes", with the thought that you don't really mean "import from one form to another" but "reference an object on one form from another form that is open at the same moment"

    Just navigate in the expression builder in the left hand frame under Forms and drill down to the form you want. That will give you the list of available objects on that form.

    It's easier if you make sure the form is open at that time so you can find the form under "Loaded forms"; avoids the need to search a potentially long list under "All Forms."

    Note the coding that the builder comes up with and in the future you may find it easier to just type it yourself. It will be something like Forms!formname! objectname!even torproperty.

    You can change the color of objects on the other form or retrieve a value and maybe even fire an event on the other form and lots of other cool stuff.

    Jim
    Last edited by jimatqsi; Jun 25 '10, 10:49 AM. Reason: add fine detail

    Comment

    • RWREBB
      New Member
      • Jun 2010
      • 4

      #3
      Originally posted by jimatqsi
      I'm going to give you a qualified "yes", with the thought that you don't really mean "import from one form to another" but "reference an object on one form from another form that is open at the same moment"

      Just navigate in the expression builder in the left hand frame under Forms and drill down to the form you want. That will give you the list of available objects on that form.

      It's easier if you make sure the form is open at that time so you can find the form under "Loaded forms"; avoids the need to search a potentially long list under "All Forms."

      Note the coding that the builder comes up with and in the future you may find it easier to just type it yourself. It will be something like Forms!formname! objectname!even torproperty.

      You can change the color of objects on the other form or retrieve a value and maybe even fire an event on the other form and lots of other cool stuff.

      Jim
      Thanks, Jim and yes I would like to retrieve a value instead. Does the same process apply?

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        Yes, you just use that method to reference an object on another form, whether you are retrieving the value of the object or trying to change the object.

        Jim

        Comment

        • RWREBB
          New Member
          • Jun 2010
          • 4

          #5
          Originally posted by jimatqsi
          I'm going to give you a qualified "yes", with the thought that you don't really mean "import from one form to another" but "reference an object on one form from another form that is open at the same moment"

          Just navigate in the expression builder in the left hand frame under Forms and drill down to the form you want. That will give you the list of available objects on that form.

          It's easier if you make sure the form is open at that time so you can find the form under "Loaded forms"; avoids the need to search a potentially long list under "All Forms."

          Note the coding that the builder comes up with and in the future you may find it easier to just type it yourself. It will be something like Forms!formname! objectname!even torproperty.

          You can change the color of objects on the other form or retrieve a value and maybe even fire an event on the other form and lots of other cool stuff.

          Jim
          Just to be clear. Am I doing this under the Data tab using the control source property?

          Comment

          • RWREBB
            New Member
            • Jun 2010
            • 4

            #6
            Originally posted by jimatqsi
            Yes, you just use that method to reference an object on another form, whether you are retrieving the value of the object or trying to change the object.

            Jim
            this is the code that I have in the control source property: =Forms!frmMSFee s!WFFeesTotal

            I'm getting an error message

            Comment

            • jimatqsi
              Moderator Top Contributor
              • Oct 2006
              • 1293

              #7
              Hmm, now that's a construction I would not have thought of. Very clever. Hmmmm ... well, I don't know if you can do that or not. Moreover, I don't know how that would be practical. When form frmMSFees changes, you would need something to fire this form to read the change, which I suppose could be an afterUpdate event, maybe.

              You don't say what your error is, so it's impossible to make any comment about that. Maybe the other form is not loaded, maybe Access doesn't like this in a control source.

              Normally, for me anyway, when form B is reading something from form A, form B has been opened by form A, either as a subform of form A or a pop-up window doing some specific task related to form A. Like, I have several forms with a credit card button, and if the user hits the credit card button on any of these forms, they all launch the credit card data entry pop-up form. It figures out which main form is open and from that figures out which customer it is getting the credit card data for editing and submission for authorization.

              So, usually, I'm saying somethng like this (on form B) in response to some event on form B, which was likely opened by form A:
              Code:
              me!txt123 = Forms!frmA!txt456
              and maybe I'll follow that with additional data collection from form A to form B before form B does something useful, then closes and the user is returned to form A.

              So it would be useful to know what you are doing. What is the purpose of transferring this data from form MSFees to form B? If you want the data on form B to track along with the data on form MSFees, maybe it would be better to make form B a subform (a form within a form) of MSFees, and link the two forms with a master/child key relationship. That way, when you change records on form A, the data on form B is automatically changed to show a corresponding record.

              For instance, on a Customer screen, form A might have the name, address, salesman, terms and so on for the customer, and form B might have all the open orders for that customer. As soon as you change customers on the customer master form, of course you want the subform showing data related to the newly selected customer.

              So what is your situation? What are doing and how does form B relate to MSFees?

              One more thing, keep in mind that when you put a formula in a data source, you are making that text box (or whatever the object is) read-only, it is for viewing only. Obviously you can't change the data because the control source is not a data item or blank.

              Jim
              Last edited by jimatqsi; Jun 26 '10, 11:17 AM. Reason: correction

              Comment

              Working...