Results 1 to 9 of 9
  1. #1
    Nimo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14

    Matching id values between two tables

    Hi, I have two tables, one has two fields:
    student ID and student name

    its kind of like this:

    1 Mark
    2 Tom
    3 Franklin

    the other table has three fields: student name, student classes, it goes like this:

    Mark calculus
    Mark Biology
    Tom Statistics
    Franklin Calculus
    Tom Chemistry


    what I want is for the second table to have its related id from the first table so it could be like this:

    1 calculus


    1 biology
    2 statistics
    3 calculus
    2 chemistry

    Is this possible ?


    I cant simply make find and replace because the records are a lot is there another way should I relate the tables of something how will it work?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    This is simply a matter of creating a query using these two tables, joining on the Student Names fields in each table.
    Then, just have the query return the ID field from the first table, and Class field from the second table.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Make Upd qry and join the 2 tables on NAME, and update the [ID] fld.

  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,919
    The StudentID field is Number type (Autonumber)? Add a number type field to Table2. Build query that joins the tables on the name fields. Assumes no names are duplicated for different students (there is only one student named Tom). Change the query to an UPDATE. Populate the new field with ID value from Table1. If all correct, delete the name field from Table2.
    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
    Nimo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14
    I just tried this when I hit run I get nothing.. I hit the update option and typed [table1]![Id] and I hit run but nothing happened.. this is a screenshot:

    http://i725.photobucket.com/albums/w...ps64851ddd.png


    did I do it wrong?

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you may need to make the NAME field on the left hand table a primary key (temporarily) so that the recordset is updatable.

  7. #7
    Nimo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14
    I did what you said, the query runs but still returns an empty ID field it didn't update it didn't take the value from the 1st table

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Please switch your query to SQL View, and copy and paste your SQL code here.

  9. #9
    Nimo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    14
    It turns out the run option didn't return any values because the enable content option was disabled from the access settings.. I luckily figured it out when I was trying to append records to a different database and a window popped up.. The run update returned the records it worked guys, thank you so much !

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

Similar Threads

  1. Replies: 2
    Last Post: 01-16-2014, 09:00 AM
  2. Replies: 3
    Last Post: 07-19-2012, 06:51 AM
  3. Matching based on criteria from multiple tables
    By Jonpro03 in forum Database Design
    Replies: 13
    Last Post: 08-04-2011, 10:29 AM
  4. Matching between 2 tables
    By slevin in forum Access
    Replies: 1
    Last Post: 06-16-2010, 07:28 AM
  5. Can Microsoft Access Matching Values?
    By Toniol in forum Access
    Replies: 0
    Last Post: 12-23-2008, 05:35 PM

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