Results 1 to 2 of 2
  1. #1
    ConstructionBoss is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    1

    Create a Query that looks up price based on date purchased, material code, po#, etc.

    I would like to have a Query in my database that returns what the price should be for materials we purchase. The price is dependent on multiple factors.

    Factors:
    1) Prices adjust on various days for various materials at various locations. I need to match the material purchased to the price in effect after the date in tblPrice_Updates
    2) The prices are linked to an OP number (a Purchase Order, our shorthand nomenclature is backwards!) and a Plant Number I use this OP number in tblMaterial_Purchased in a combo select box so the person entering data can pick the correct OP based on the other values (Vendor Name and Plant Number)
    3) In the tblMaterial_Purchased they enter the Kit_Number (Material Code) to determine what we bought. This field is also in tblPrice_Updates.

    The idea is that after putting in the date, Kit_Number, Plant_Number (Probably irrelevant for the Query since the OP_Number is tied to specific plants), and the OP_Number in tblMaterial_Purchased, the new query would return a price for each line based on the date bought.



    Attached is a sable database that had been sanitized.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    This can be very tricky. Consider this method:

    SELECT tblMaterial_Purchased.*, DLookUp("Current_Price","tblPrice_Updates","Kit_Nu mber=" & [Kit_Number] & " AND OP_Number=" & [OP_Number] & " AND [Effective_Date]=#" & DMax("Effective_Date","tblPrice_Updates","Kit_Numb er=" & [Kit_Number] & " AND OP_Number=" & [OP_Number] & " AND [Effective_Date]<#" & [Date] & "#") & "#") AS Price FROM tblMaterial_Purchased;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-04-2012, 02:46 AM
  2. Replies: 5
    Last Post: 08-07-2012, 11:14 AM
  3. Code to create a query from a form
    By stryder09 in forum Queries
    Replies: 15
    Last Post: 10-17-2011, 01:55 PM
  4. query to update a date based on another date
    By tkendell in forum Access
    Replies: 3
    Last Post: 06-29-2011, 09:32 PM
  5. Replies: 0
    Last Post: 02-15-2009, 09:14 PM

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