Results 1 to 5 of 5
  1. #1
    JRodko is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    127

    Select numbers from one table to update another based on matching string.

    I have attached an example DB to make things easier.



    I am trying to update records in the "Header" table with values found in the "Lithology" table.

    In header, I'd like to copy the "To" depth out of Lithology and into the header field "Depth_B" WHERE the code field (Lithology table) = "B". This needs to be done only for the hole id that matches in tblSelectedDrillHole (TEST19-02)

    I'd also like the query to take the "From" depth form lithogloy where code = "U" and copy that value into the header field "Depth_U"

    I'd also like to update the header field "Date_Completed" with the current date.

    Finally, I'd like the header field "Depth_E" to be updated with the largest "To" value based on the selected drill hole.

    Perhaps looking at the example database will clarify my description. There is a sample project "TEST19-03" which demonstrates how the values should be used to update the corresponding project in the Header table. As of now I am thinking this would be best with a series of queries?

    samplecopydepths.zip

    Thank you.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Can you have a look at the attached (query1) and see if that is what you want?

    Cheers,
    Vlad
    Attached Files Attached Files

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is a VBA example instead of using multiple saved queries.
    Attached Files Attached Files

  4. #4
    JRodko is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    127
    Wow. Thank you both very much. I always forget about the self join. Silly me.

    I have gone with Vlad's solution because I am fairly new to access and I understand it through and through.

    Steve - Thank you for the VBA solution. I hope to get to your level one day.

    Cheers to both of you.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Good luck with your project!

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

Similar Threads

  1. Replies: 2
    Last Post: 01-09-2019, 06:41 PM
  2. Replies: 5
    Last Post: 03-30-2018, 12:23 PM
  3. Replies: 22
    Last Post: 01-23-2015, 01:16 PM
  4. Replies: 7
    Last Post: 11-24-2014, 02:11 PM
  5. Replies: 4
    Last Post: 08-30-2012, 07:58 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