Trouble Linking Fields In Subform To Auto Populate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GODSPEEDELECTRONICS
    New Member
    • Jun 2008
    • 9

    Trouble Linking Fields In Subform To Auto Populate

    I have a subform, and what I'm trying to do is get field "price" to auto populate when I type in something under "iteminstal l".
    I have a table named "Price List", and the only columns on it are "iteminstal l", and "price".
    I was able to find a previous post on this issue, and though it worked in that case,it isn't working for me.
    In the subform, "iteminstal l" is a combo box, and price is a text box.
    Any pointer would be greatly appreciated.
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    In the Price Field add the following function to the Control Field on the control Price
    Code:
    =Dlookup("Price","[PriceList]",[ItemInstalled]='" & [ItemInstalled] & "'")
    This is assuming a few things.
    1. PriceList is the name of the table that has the field ItemInstalled, and Price.
    2. The name of the control that is the combo box is names "ItemInstalled" .
    3. The name of the Price field is named "Price" also.

    This will do a lookup based the value that is entered in Combo Box "ItemInstal led" and set that value to lookup the price.

    If you have any more questions, please feel free to let me know.

    Joe P.

    Comment

    • GODSPEEDELECTRONICS
      New Member
      • Jun 2008
      • 9

      #3
      Originally posted by PianoMan64
      In the Price Field add the following function to the Control Field on the control Price
      Code:
      =Dlookup("Price","[PriceList]",[ItemInstalled]='" & [ItemInstalled] & "'")
      This is assuming a few things.
      1. PriceList is the name of the table that has the field ItemInstalled, and Price.
      2. The name of the control that is the combo box is names "ItemInstalled" .
      3. The name of the Price field is named "Price" also.

      This will do a lookup based the value that is entered in Combo Box "ItemInstal led" and set that value to lookup the price.

      If you have any more questions, please feel free to let me know.

      Joe P.
      I copied and pasted exactly what you wrote into "control source" for 'price' on my subform.. It did not work, so I went back to double check that it was typed right, and "price" was in control source. I pasted again, but everytime I leave design view, it reverts back to price. Also, do I have to put anything in the quotation marks? Or are they supposed to be empty?

      Comment

      • GODSPEEDELECTRONICS
        New Member
        • Jun 2008
        • 9

        #4
        Originally posted by GODSPEEDELECTRO NICS
        I copied and pasted exactly what you wrote into "control source" for 'price' on my subform.. It did not work, so I went back to double check that it was typed right, and "price" was in control source. I pasted again, but everytime I leave design view, it reverts back to price. Also, do I have to put anything in the quotation marks? Or are they supposed to be empty?
        Would it be possible for me to email you the database for you to look at, or upload it somewhere. I have nothing to hide, I just want to get it fixed.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          I'm sorry, but we do not offer to do your work for you, simply help you to understand what you're doing better.

          Try the following. If it doesn't work, explain what is going wrong where and we'll see what we can see for you.
          Code:
          =DLookup("[Price]","[Price List]",[ItemInstalled]='" & [ItemInstalled] & "'")
          Make sure that all the field and control names match what you have in your database.

          Comment

          • GODSPEEDELECTRONICS
            New Member
            • Jun 2008
            • 9

            #6
            Originally posted by NeoPa
            I'm sorry, but we do not offer to do your work for you, simply help you to understand what you're doing better.

            Try the following. If it doesn't work, explain what is going wrong where and we'll see what we can see for you.
            Code:
            =DLookup("[Price]","[Price List]",[ItemInstalled]='" & [ItemInstalled] & "'")
            Make sure that all the field and control names match what you have in your database.
            Thank you for your help.

            I was able to get that working by using the combo box wizard. All it changed was the following: the bound column detail was changed to "2", but now I'm having another problem. It the footer of the subform, I have the expression:
            =Sum([price]*[qty]).
            On the main form I have a text box that links to this field, to display a subtotal. Now the price is autopopulating in the subform, but it is not changing my subtotal. The existing subtotal is still there, but If I add anything to the order, it won't update to the new subtotal. Instead, it continues to display the old subtotal.

            I added a new record, and tried entering some new data, but subtotal is outputing "0". Any Ideas?

            Comment

            • GODSPEEDELECTRONICS
              New Member
              • Jun 2008
              • 9

              #7
              Originally posted by GODSPEEDELECTRO NICS
              Thank you for your help.

              I was able to get that working by using the combo box wizard. All it changed was the following: the bound column detail was changed to "2", but now I'm having another problem. It the footer of the subform, I have the expression:
              =Sum([price]*[qty]).
              On the main form I have a text box that links to this field, to display a subtotal. Now the price is autopopulating in the subform, but it is not changing my subtotal. The existing subtotal is still there, but If I add anything to the order, it won't update to the new subtotal. Instead, it continues to display the old subtotal.

              I added a new record, and tried entering some new data, but subtotal is outputing "0". Any Ideas?
              Now I'm back to trying the after update method. I'm getting this error.

              The expression After Update you entered as the event property setting produced the following error: The object doesn't contain the automation object 'iteminstalled. '.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                I suggest you consider reposting your current issue with a bit more clarity.

                Do you realise you just posted an error message without even including the code that caused the error. We may be good, but not THAT good.

                PS. Your explanation could do with some work too, if you would like someone to respond.

                Comment

                • GODSPEEDELECTRONICS
                  New Member
                  • Jun 2008
                  • 9

                  #9
                  Originally posted by NeoPa
                  I suggest you consider reposting your current issue with a bit more clarity.

                  Do you realise you just posted an error message without even including the code that caused the error. We may be good, but not THAT good.

                  PS. Your explanation could do with some work too, if you would like someone to respond.
                  The code I used was the dlookup code from the last post before mine. Apologies for lack of clarity.
                  Last edited by NeoPa; Jun 25 '08, 11:16 AM. Reason: Removed all caps.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32661

                    #10
                    Please don't simply ignore anything that you don't find convenient.

                    Posting the actual code you used (rather than my template where I say explicitly to change where necessary to match you own situation) was requested and ignored. The whole question is a poorly explained mess that needs clarifying.

                    This YOU need to do before expecting others to jump in and make any sense of this.

                    I'm sorry to express this so strongly, but you seem to ignore it when it's said more delicately.

                    Comment

                    • mshmyob
                      Recognized Expert Contributor
                      • Jan 2008
                      • 903

                      #11
                      For your subtotal problem. Try changing your main form value from inside the subform.

                      For instance in your subform you would have some code like so:

                      [code=vb]
                      Forms!frmMain.t xtSubTotal= Me.txtSubTotal2
                      [/code]

                      Here we have a Subtotal in the subform (txtSubTotal2) and a subtotal in the main form (txtSubTotal). Put this code inthe SUBFORM not the main form.

                      cheers,

                      Originally posted by GODSPEEDELECTRO NICS
                      Thank you for your help.

                      I was able to get that working by using the combo box wizard. All it changed was the following: the bound column detail was changed to "2", but now I'm having another problem. It the footer of the subform, I have the expression:
                      =Sum([price]*[qty]).
                      On the main form I have a text box that links to this field, to display a subtotal. Now the price is autopopulating in the subform, but it is not changing my subtotal. The existing subtotal is still there, but If I add anything to the order, it won't update to the new subtotal. Instead, it continues to display the old subtotal.

                      I added a new record, and tried entering some new data, but subtotal is outputing "0". Any Ideas?

                      Comment

                      Working...