Results 1 to 6 of 6
  1. #1
    Prevost is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    11

    Updating Field in Table2 with Table1 values based off matching criteria

    I created these two tables (Table1 and Table2) and realized that I have redundant fields in Table2. I have entered frame numbers and frame costs in Table2 when the corresponding ID from Table1 (which contains the frame numbers and frame costs that are identified with the ID) can be used instead. I want the SQL (or query) to look at the FrameNo field in Table2 and find the correct ID from the records in Table1 that has the same FrameNo field value then enter in that ID number to my newly created field in Table2. The field that I am updating is of Long Integer type, not Autonumber.





    Thanks in advance.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    How about telling us a little about your database, the tables and how they relate? What's a frame etc?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Build an UPDATE query.

    First build a query that joins the two tables on the common frame numbers and frame costs fields. Click UPDATE from the ribbon query design. Set the Update To row under the Table2 ID field to the Table 1 ID field. Run query. Make sure update is correct then delete redundant fields from Table 2.
    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.

  4. #4
    Prevost is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Thanks for the responses! To reply to orange, the data base is for electric motors and their configurations. I have imported data from Excel into Access and am trying to configure it so I can eventually make cascading drop down boxes to refine/select the available features of a certain motor.

    My Table1 contains the basic unwound frame motor (basically it's like an electric motor but without any of the electrical components inside) information. The identifier is ID and then there are fields of UWFrameNo, Size & Cost.

    My Table2 contains all of our configurations for those frames (we insert the copper wires, make connections, make modifications to the shaft, etc) and so there are multiple fields for each record in this table. They include Horsepower1, Horsepower2, RPM1, RPM2 and so on.

    I am new to Access and in my Table2 with all the configurations, I put in the UWFrameNo (field also in Table1) and the Cost (also in Table1). What I should really have in Table2 in place of UWFrameNo and Cost, is the unique identifier from Table1 that I can then use to pull all the other properties if required. I have created a relationship (Parent is Table1 and Child is Table2) between the ID in Table1 to the UWFrameID in Table2 so that I cannot have a configuration without a valid frame.

    June7, I don't understand what your first sentence means? All the frame numbers in Table2 (but can appear in more than one record) exist in Table1.

    Thanks.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    If you want to populate Table2 with ID from Table1, first build a query that joins tables on the common fields (maybe just FrameNumber and not FrameCost fields) - join type "Include all records from table2 ...". Then click UPDATE on the ribbon to switch query type. Set the UpdateTo row under the ID field in Table 2 to the ID field from Table1. Run query.
    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
    Prevost is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Thanks for all the responses. Here is where the answer is...

    http://www.mrexcel.com/forum/microso...ml#post3887677

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

Similar Threads

  1. TABLE1 VS TABLE2...Are all ID's from Table1 in Table2???
    By smoothlarryhughes in forum Queries
    Replies: 11
    Last Post: 10-26-2012, 11:28 AM
  2. Replies: 8
    Last Post: 07-08-2012, 02:20 PM
  3. Replies: 9
    Last Post: 06-28-2012, 10:10 PM
  4. Copy values from table1 to table2
    By wubbit in forum Queries
    Replies: 2
    Last Post: 04-19-2012, 04:40 PM
  5. Replies: 5
    Last Post: 08-20-2010, 06:40 AM

Tags for this Thread

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