Results 1 to 7 of 7
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    append value to history table and update current value

    I have searched the forum but can't quite find what i am looking for on this.



    I have form1 that has the current commodity
    When i need to change the commodity I want the following to happen when they click a button:
    1. open the commodity change form
    2. that form has a drop down to select a new commodity and a date of commodity change date field
    3. When the user submits it will move existing value to history along with the Date of change (separate table)
    4. Next it will take the value in the new commodity box and make it the current commodity


    My thinking is that when i click the button to open the change form I can save the commodity at that time but I wont have the date yet. Just not sure of they best way to go about this.
    Thanks for any help

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    More conventional approach is to just mark record as 'inactive', not move to another table.

    What is 'commodity' and what exactly is being changed?
    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.

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Sorry the commodity is the last contents in a railcar. So the railcar is carrying one type of oil or chemical or whatever. then another customer uses it and we need to record what the last commodity was and what the current one is so we can't mark it as inactive because it is just one field in a much larger list of fields

  4. #4
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Sounds like you may want to use a multi to multi relation join table.

    3 tables:
    1)RailCarTable----RailCarID, RailCarName, Date, etc.
    2)CommodityTable------CommodityID, TypeOfCommodity
    3)RailCarCommodityTable----NewID, RailCarIDFK, CommodityIDFK

    OR

    Before changing the commodity and date, run an append query first. Then you can simply update the record in your orignal table, and now you have the "new" record in your primary table and "old" record in your append table.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I agree with cbende2. I think your data structure is not optimized

    And the RailCarCommodityTable needs date field. This table would have 'transactions' that document contents of rail cars over time. This provides history as well as current status without having to juggle records between tables.
    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.

  6. #6
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Thanks for the help. I created a new table as suggested to take the many to many join and create two one to many joins and now it is doing what I want.
    Thanks

  7. #7
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Awesome! Great to hear back that it's working!

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

Similar Threads

  1. append/overwrite (update?) junction table from Excel
    By Atoga in forum Import/Export Data
    Replies: 3
    Last Post: 04-30-2015, 02:34 AM
  2. Update and Append Entire table in Access
    By Yoyo120 in forum Access
    Replies: 1
    Last Post: 06-05-2014, 02:42 PM
  3. Replies: 4
    Last Post: 05-13-2014, 12:24 PM
  4. Replies: 4
    Last Post: 03-10-2014, 11:33 AM
  5. Replies: 3
    Last Post: 09-18-2011, 03:46 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