Results 1 to 3 of 3
  1. #1
    1953hogan is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    10

    Update field in one form with data from related form

    Here are my two tables:

    Table #1: Inventory
    Fields:
    ID
    Description
    Price

    Example records in Table1:

    ID: 1
    Description: Bicycle
    Price $100.00



    ID: 2
    Description: Helmet
    Price: $50.00

    Table #2: PriceHistory
    Fields
    ID
    ItemID
    PriceDate
    Price

    Examples of related records in table 2:
    ID: 1
    ItemID: 1
    PriceDate: 5/1/11
    Price $100.00

    ID: 2
    ItemID: 2
    PriceDate: 5/1/11
    Price $50.00

    ID: 3
    ItemID: 1
    PriceDate 6/1/11
    Price: $150.00

    ID: 4
    ItemID: 2
    PriceDate: 6/1/11
    Price $60.00

    Table1 ID field is joined to Table2 ItemID field (one to many with table2 being the "many" subform).

    As prices change for an inventory item, a new record is placed in table2 showing the date and the price as of that date (per the sample records). Table2 therefore holds a complete history of the pricing of every item in table #1.

    What I would like to do is to write an update query that updates the PRICE field of every record in Table1 with the MOST RECENT PRICE for each item from Table2.

    Example:
    The price for "Bicycle" should be updated to $150.00, and the price for "Helmet" should be updated to $60.00

    Can somebody help me with this? Thanks so much!

    Steve

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The simple solution is to not store the price in your inventory table, there's no point to storing it in two locations if you only care about the most recent price. I am assuming your prices will never go down so when you want to run an inventory total just connect the two tables through the ID field and choose the MAX(price) from your PRICEHISTORY Table.

    If your prices *may* go down you can still do it this way but it would also be an easy fix. On which ever reacord in your PRICEHISTORY table you want to figure your inventory value by have another field called 'currentrecord' which is yes/no, and when you link the INVENTORY table to the PRICEHISTORY table only choose the records that are marked YES (or -1) from the CURRENTRECORD field.

  3. #3
    1953hogan is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    10

    thanks

    I see your point and will take your advice. Thanks!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2013, 11:42 AM
  2. Form using VBA to update field on table
    By comicwizard in forum Programming
    Replies: 3
    Last Post: 04-05-2011, 11:17 AM
  3. Show related data on a form
    By Accessgrasshopper in forum Forms
    Replies: 4
    Last Post: 03-17-2011, 07:53 PM
  4. Replies: 4
    Last Post: 12-21-2010, 11:32 AM
  5. Open form on update of field in another form.
    By thekruser in forum Forms
    Replies: 5
    Last Post: 09-13-2010, 02:12 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