Results 1 to 14 of 14
  1. #1
    GregShah is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68

    Trouble with DLookup on Subform

    I have attached a simplified version of my DB with this post.



    I have a table CID Base Price list. The CID is the primary key and is the item number of my structures. This table also has the base price of this item which gets adjusted quarterly based on the type of structure. I use a query called Currentprice to make this price adjustment for each CID.

    The other tables involved are a table called Job which assigns a number to our project. Attached to the Job table is a table called PODetail. This lists the quantity and CIDT for whatever items my customer is ordering. I added the T to cid because I thought using the same name could be causing my grief.

    Finally, I tried to create a form/subform which will allow me to open a job number and then enter the quantity, CID in a subform. I want the subform to lookup the current price in my query. I cannot get this function working. I listed four different formats I tried to know avail.

    Can anyone see where I am going wrong?

    Thanks for the effort,

    Greg
    Attached Files Attached Files

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Numerous problems, solutions include:

    =DLookUp("[current price]","currentprice","cid='" & [Forms]![job]![podetail subform].[Form].[CIDT] & "'")

    =DLookUp("[current price]","currentprice","cid='" & [CIDT] & "'")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I'm confused, where are the multiple prices supposed to come from? Why are their 4 price columns? Sorry if I'm missing something...

  4. #4
    GregShah is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    Thank you. I could not find a good source for the proper formatting even though I looked on several sites. I appreciate your help. I was really getting discouraged.

    Thanks again.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    No problem, PBaldy has the correct language for you. :-)

  7. #7
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Quote Originally Posted by Gina Maylone View Post
    No problem, PBaldy has the correct language for you. :-)
    Sorry just realized that wasn't for me!

  8. #8
    GregShah is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    New issue with my form/subform. I used three different methods to add the CID to my subform. I need to select one method, either a combo box based on the table CID base price list or the query Currentprice. The third method was just entering the CID as a ten digit number. When I eliminate one or two of these fields, the current price no longer displays on my subform. Not sure why?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    If having a combo based on the query is an option, I'd get rid of the DLookup's and use this:

    BaldyWeb - Autofill

    It's more efficient than repeated trips to the data.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    GregShah is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    Even more confusion on my end. I deleted the four attempts I made to use dlookup and then save the form and subform. Now the current price is no longer displayed. I thought it was related only to the combo boxes I used to identify the CID. The other boxes all return errors. Why would deleting these derail the dlookup?

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Hard to say without seeing the db, but presumably the DLookup referred to a deleted control or field. Did you consider the option in post 9?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    GregShah is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Canton, Ohio
    Posts
    68
    I considered but I need to use the current price in a calculated field to determine the qty*currentprice to verify the total on the PO. Not sure if this is possible using option in #9.

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Normally I'd be saving the current price with the transaction, so dropping it into a bound field should allow it to be used in further calculations.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Difficult to know exactly what another person would want, but I played with this for some time. Check it out - too many changes to the forms to recall all of them. You'll see some controls are disabled to prevent user from changing source data, such a pricing. Generally, a datasheet is not appropriate for data input. If you want to keep close to what you had, you should be able to work with the attached. Note that I started by copying your two forms and renamed stuff, but couldn't keep it straight as to which I was looking at (the form captions threw me off) so I dumped the originals. The lookup is now
    =DLookUp("[Base Price]","[CID Base Price List]","[CID] = '" & [Forms]![Job2]![PODetail Subform].[Form]![Combo6] & "'")
    Hopefully you will pick up some hints for going forward by reviewing the design changes.

    Test DB2.zip
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trouble with macro within a subform
    By MLangendorf in forum Forms
    Replies: 12
    Last Post: 12-13-2016, 01:22 PM
  2. Trouble with DLOOKUP in a Subform
    By Mubashir sabir in forum Forms
    Replies: 2
    Last Post: 08-21-2015, 01:38 PM
  3. Subform Requery Trouble
    By ztpkng in forum Forms
    Replies: 2
    Last Post: 06-19-2014, 04:02 PM
  4. Replies: 2
    Last Post: 03-06-2013, 11:37 PM
  5. Replies: 13
    Last Post: 11-02-2012, 01:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums