Results 1 to 7 of 7
  1. #1
    MCE is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    4

    Access 2007 updating one table based on another table

    Hi,



    Im pulling my hair out, no matter what way i do it i cannot get one field in one table to update a field in another table.

    I have followed microsofts step by step instructions and still does not work.

    Here is a link for the instructions: http://office.microsoft.com/en-au/ac...010076527.aspx

    Any help or advice would be much appreciated, losing my patience with it.....

  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
    Post the SQL statement you attempted. Or provide db - follow instructions at bottom of my post.
    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
    MCE is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    4
    Hi, thanks for your reply

    I want the value in the location field in table1 to update the value in the location field in table2

    this is the SQL command im using:

    UPDATE Table1 INNER JOIN Table2 ON (Table2.Location = Table1.Location) AND (Table1.Location = Table2.Location) SET Table2.Location = [table1].[location];

    If you need still need the db just let me know and ill follow your instructions and post it.

  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,929
    Why the second join?

    UPDATE Table1 INNER JOIN Table2 ON (Table2.Location = Table1.Location) SET Table2.Location = [table1].[location];
    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
    MCE is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    4
    This SQL statement was created by access.

    I tried without the second join and i still get "You are about to update 0 row(s)" ?????????????

  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,929
    Access would create those joins only if they are established in the Relationships window.

    Could try reversing the join tables

    UPDATE Table2 INNER JOIN Table1 ...

    Beyond that, have no idea why this fails.
    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
    MCE is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    4
    Got it!!

    According to the microsoft instructions i posted the link to above, I have to join the tables:


    • If the tables aren't already joined, join them on the fields that have related information.

    How?
    In most cases, you want to bring together or perform an action on data from more than one table or query. For example, you might want to view a customer's information with the orders the customer placed. To see this information, you need data from the Customers and Orders tables.
    Join different tables and queries

    • In query Design view, drag a field from the field list for one table or query to the equivalent field (a field of the same or compatible data type containing similar data) in the field list for the other table or query.


    With this type of join, Microsoft Access selects records from both tables or queries only when the values in the joined fields are equal.
    Note Join numeric fields only if the FieldSize property settings for both are Byte, Integer, or Long Integer.

    In some cases, you want to join two copies of the same table or query, called a self-join, that combines records from the same table when there are matching values in the joined fields. For example, say you have an Employees table in which the ReportsTo field for each employee's record displays his or her manager's ID instead of name. You could use a self-join to display the manager's name in each employee's record instead.

    I removed the join in the relationships window and did not drag and drop the corresponding fields and Eureka it worked perfectly.

    Thanks for all your help.


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

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2013, 07:22 PM
  2. Replies: 6
    Last Post: 05-10-2012, 08:20 PM
  3. Query isnt updating table based on criteria
    By shabbaranks in forum Queries
    Replies: 12
    Last Post: 01-10-2012, 11:51 AM
  4. Replies: 3
    Last Post: 08-08-2011, 11:02 AM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 AM

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