+ Reply to Thread
Results 1 to 7 of 7

Connect 4 fields from 2 tables rather than updating both

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,243

    Connect 4 fields from 2 tables rather than updating both

    Hi all, as is usual a situation has arisen that I need to update records on two tables within an access workbook. I could just update both tables by referencing them separately through vba but wonder is it easier to link the common fields within access so that when one table is updated the changes are reflected in second table.

    Database is currently functioning so I am hoping not to have to make radical changes at this point.

    Basically it is table1 and table2 with 4 common fields named the same

    Any pointers appreciated

    I created the relationship between the 4 fields in the 2 tables and the relationship lines a re in the right place but I am guessing this is not the way to go as updates to one table are not reflected, how can I address the two records linked by ID2 and update the 4 fields in both with one Query through ADO from VBA

    at the moment update finds ID2 on tblDelivered and updates 'Charge' and one of 'Cash' 'Card' or 'Cheque' but I am guessing the two records could be addressed at the same time
    Attached Images Attached Images
    Last edited by nigelog; 08-19-2021 at 03:35 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,449

    Re: Connect 4 fields from 2 tables rather than updating both

    A normalized Data Base does not have the same items in two tables. Your data should be unique to only one table. You can then create relationships between the tables using primary keys and foreign keys. With your current design you will continue to have issues which will affect your outputs. I have attached for your benefit a white paper on Relational Data Base Design.
    Attached Files Attached Files

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,243

    Re: Connect 4 fields from 2 tables rather than updating both

    Thanks Alan I'll have a read. Unfortunately with this project starting to be used I'm too late for radical design. As a first project I'm lucky to have got this far. I'll Have to go with an update query but get the following...
    Attached Images Attached Images

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,449

    Re: Connect 4 fields from 2 tables rather than updating both

    I suspect that one field in one of the tables is numeric and the other one is text.

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,243

    Re: Connect 4 fields from 2 tables rather than updating both

    @ Alan, Correct Alan, now just need to work out how to update only the record identified by ID2

    @ all, I created a search query to select an individual ID2 number that does return the data to the database view when run (I used record 199 before I adapt for a variable) - and I created an update query that identifies the fields I want update but when I run both queries manually in order no record is updated

    I hope to run these queries eventually from a userform sub but its the tables links are avaiding me....

    Any help appreciated..workbook attached....AAAh, apparently cant upload access workbook
    Attached Images Attached Images
    Last edited by nigelog; 08-18-2021 at 05:51 AM.

  6. #6
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,243

    Re: Connect 4 fields from 2 tables rather than updating both

    I had it all backwards finally have update query working
    Please Login or Register  to view this content.
    need now to find out how to convert to include in a recordset sub
    Last edited by nigelog; 08-18-2021 at 09:03 AM.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,449

    Re: Connect 4 fields from 2 tables rather than updating both

    BTW,
    For the future, you can upload an Access File, but you need to Zip the file first.

    Alan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Connect two tables
    By rokandil in forum Excel General
    Replies: 3
    Last Post: 07-08-2019, 07:02 AM
  2. [SOLVED] Powerpivot, need connect fields in two table, which has duplicates
    By Reykjavik in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 02-07-2018, 12:55 PM
  3. [SOLVED] How to connect two different sets of data through a single slicer with 5 common fields?
    By dev.jajati in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-29-2016, 03:40 PM
  4. How to connect Excel fields to external data
    By Matharoo in forum Excel General
    Replies: 0
    Last Post: 11-24-2014, 02:08 PM
  5. Replies: 0
    Last Post: 03-22-2013, 09:08 AM
  6. connect tables
    By kwarcek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2010, 05:44 AM
  7. How do I connect fields from two spreadsheets
    By The Good Deeds Team in forum Excel General
    Replies: 12
    Last Post: 02-18-2005, 10:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1