Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53

    Update Data from one table with another?

    Hello I have two tables, when a module is run I would like the Ship_Dates Table to be updated with the 'New' dates in the Change_Orders table. I have tried to come up with a solution but can't think of anything. Any help would greatly be appreciated.

    Example

    Ship_Dates Table:

    Project_Number ShipmentNumber Sched_Ship_Date Actual_Ship_Date Notes
    1020 1 28/07/2014 Test
    1020 2 29/07/2014 Test

    Change_Order_Dates Table:

    Change_Number Project_Number ShipmentNumber Current_Ship_Date New_Ship_Date
    10 1020 1 28/07/2014 3/08/2014
    10 1020 2 29/07/2014 4/08/2014

    Ship_Dates Table after module is run:

    Project_Number ShipmentNumber Sched_Ship_Date Actual_Ship_Date Notes
    1020 1 3/08/2014 Test
    1020 2 4/08/2014 Test


  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    One way would be to simply run an update query using the afterupdateevent of your ship delivery table.

  3. #3
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by burrina View Post
    One way would be to simply run an update query using the afterupdateevent of your ship delivery table.
    I tried making an update query but it didn't make much sense to me, what would I put for the UpdateTo field?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Why do you need the Ship_Delivery_Dates table? Why not just query the Change_Order_Dates table? Or why the Change_Order_Dates table instead of data entry/edit directly in Ship_Delivery_Dates?
    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.

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Update Data From One Table To Another Table

    It would be an append query using a Destination table. Here is a screenshot example.
    Oops, it should be an update qry! But you get the idea.


    HTH
    Attached Thumbnails Attached Thumbnails UpdateTableExample.png  
    Last edited by burrina; 07-28-2014 at 12:46 PM. Reason: Wrong Advice

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Burrina, I think OP wants to edit existing record. That is an UPDATE sql action.

    Start with a query that joins the tables on the Project_Number then click UPDATE on the ribbon. The Update To would be reference to the field from Change_Order_Dates.
    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.

  7. #7
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by June7 View Post
    Why do you need the Ship_Delivery_Dates table? Why not just query the Change_Order_Dates table? Or why the Change_Order_Dates table instead of data entry/edit directly in Ship_Delivery_Dates?
    I would like to keep a history of the changes made. Good idea about re-querying the Change_Order_Dates table but it wouldn't work very well in my database.

  8. #8
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    This doesn't make too much sense to me, I have this so far. How would I create criteria so that it only updates when the ProjectNumber and the ShipmentNumber are the same?

    Click image for larger version. 

Name:	Capture.PNG 
Views:	13 
Size:	18.2 KB 
ID:	17512

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Do a compound join. Link the tables in the query on the two fields in both 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.

  10. #10
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Here is an example. Of course make the changes to reflect your table names and field names. IF what you want to do is keep a history!
    Dim strSQL As String 'Log Changed ShipDate to tblOrderDates.

    strSQL = "INSERT INTO tblOrderDates (OrderDate,ProjectNo ) "
    strSQL = strSQL & "VALUES (#" & Me.ShipDate & "#, '" & Me.ProjectNo & "')"
    CurrentDb.Execute strSQL, dbFailOnError

    HTH

  11. #11
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by burrina View Post
    Here is an example. Of course make the changes to reflect your table names and field names. IF what you want to do is keep a history!

    HTH
    I don't think that would work in my case. I am trying to edit data that is already existing. An update would probably work but I don't know how to set up the joins.

  12. #12
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by June7 View Post
    Do a compound join. Link the tables in the query on the two fields in both tables.
    I'm sorry I tried looking up how to create a compound join but it still doesn't make too much sense to me.

  13. #13
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Take a look at this video tutorial. http://office.microsoft.com/en-us/ac...104092866.aspx

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    Link the two tables in query on the two common fields.
    Click one field and hold then drag to the corresponding field in other table. Then click the link line and set the join type.
    Repeat for the other pair.
    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.

  15. #15
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by burrina View Post
    Take a look at this video tutorial. http://office.microsoft.com/en-us/ac...104092866.aspx
    This didn't help very much, I don't need to change data in multiple tables. I need to change data in one table using data from another table.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-06-2013, 11:52 AM
  2. Replies: 7
    Last Post: 03-21-2013, 09:43 AM
  3. Replies: 3
    Last Post: 09-16-2012, 10:20 AM
  4. Replies: 0
    Last Post: 05-21-2012, 11:54 PM
  5. Replies: 6
    Last Post: 05-10-2012, 08:20 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